// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// `Authentication` defines the authentication configuration for API methods
/// provided by an API service.
///
/// Example:
///
/// ```norust
/// name: calendar.googleapis.com
/// authentication:
///   providers:
///   - id: google_calendar_auth
///     jwks_uri: https://www.googleapis.com/oauth2/v1/certs
///     issuer: https://securetoken.google.com
///   rules:
///   - selector: "*"
///     requirements:
///       provider_id: google_calendar_auth
///   - selector: google.calendar.Delegate
///     oauth:
///       canonical_scopes: https://www.googleapis.com/auth/calendar.read
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Authentication {
    /// A list of authentication rules that apply to individual API methods.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::AuthenticationRule>,

    /// Defines a set of authentication providers that a service supports.
    pub providers: std::vec::Vec<crate::model::AuthProvider>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Authentication {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::Authentication::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AuthenticationRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [providers][crate::model::Authentication::providers].
    pub fn set_providers<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AuthProvider>,
    {
        use std::iter::Iterator;
        self.providers = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Authentication {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Authentication"
    }
}

/// Authentication rules for the service.
///
/// By default, if a method has any authentication requirements, every request
/// must include a valid credential matching one of the requirements.
/// It's an error to include more than one kind of credential in a single
/// request.
///
/// If a method doesn't have any auth requirements, request credentials will be
/// ignored.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AuthenticationRule {
    /// Selects the methods to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// The requirements for OAuth credentials.
    pub oauth: std::option::Option<crate::model::OAuthRequirements>,

    /// If true, the service accepts API keys without any other credential.
    /// This flag only applies to HTTP and gRPC requests.
    pub allow_without_credential: bool,

    /// Requirements for additional authentication providers.
    pub requirements: std::vec::Vec<crate::model::AuthRequirement>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AuthenticationRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::AuthenticationRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [oauth][crate::model::AuthenticationRule::oauth].
    pub fn set_oauth<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OAuthRequirements>,
    {
        self.oauth = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [oauth][crate::model::AuthenticationRule::oauth].
    pub fn set_or_clear_oauth<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OAuthRequirements>,
    {
        self.oauth = v.map(|x| x.into());
        self
    }

    /// Sets the value of [allow_without_credential][crate::model::AuthenticationRule::allow_without_credential].
    pub fn set_allow_without_credential<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.allow_without_credential = v.into();
        self
    }

    /// Sets the value of [requirements][crate::model::AuthenticationRule::requirements].
    pub fn set_requirements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AuthRequirement>,
    {
        use std::iter::Iterator;
        self.requirements = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for AuthenticationRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.AuthenticationRule"
    }
}

/// Specifies a location to extract JWT from an API request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct JwtLocation {
    /// The value prefix. The value format is "value_prefix{token}"
    /// Only applies to "in" header type. Must be empty for "in" query type.
    /// If not empty, the header value has to match (case sensitive) this prefix.
    /// If not matched, JWT will not be extracted. If matched, JWT will be
    /// extracted after the prefix is removed.
    ///
    /// For example, for "Authorization: Bearer {JWT}",
    /// value_prefix="Bearer " with a space at the end.
    pub value_prefix: std::string::String,

    pub r#in: std::option::Option<crate::model::jwt_location::In>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl JwtLocation {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [value_prefix][crate::model::JwtLocation::value_prefix].
    pub fn set_value_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.value_prefix = v.into();
        self
    }

    /// Sets the value of [r#in][crate::model::JwtLocation::in].
    ///
    /// Note that all the setters affecting `r#in` are mutually
    /// exclusive.
    pub fn set_in<T: std::convert::Into<std::option::Option<crate::model::jwt_location::In>>>(
        mut self,
        v: T,
    ) -> Self {
        self.r#in = v.into();
        self
    }

    /// The value of [r#in][crate::model::JwtLocation::r#in]
    /// if it holds a `Header`, `None` if the field is not set or
    /// holds a different branch.
    pub fn header(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.r#in.as_ref().and_then(|v| match v {
            crate::model::jwt_location::In::Header(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
    /// to hold a `Header`.
    ///
    /// Note that all the setters affecting `r#in` are
    /// mutually exclusive.
    pub fn set_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Header(v.into()));
        self
    }

    /// The value of [r#in][crate::model::JwtLocation::r#in]
    /// if it holds a `Query`, `None` if the field is not set or
    /// holds a different branch.
    pub fn query(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.r#in.as_ref().and_then(|v| match v {
            crate::model::jwt_location::In::Query(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
    /// to hold a `Query`.
    ///
    /// Note that all the setters affecting `r#in` are
    /// mutually exclusive.
    pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Query(v.into()));
        self
    }

    /// The value of [r#in][crate::model::JwtLocation::r#in]
    /// if it holds a `Cookie`, `None` if the field is not set or
    /// holds a different branch.
    pub fn cookie(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.r#in.as_ref().and_then(|v| match v {
            crate::model::jwt_location::In::Cookie(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [r#in][crate::model::JwtLocation::r#in]
    /// to hold a `Cookie`.
    ///
    /// Note that all the setters affecting `r#in` are
    /// mutually exclusive.
    pub fn set_cookie<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#in = std::option::Option::Some(crate::model::jwt_location::In::Cookie(v.into()));
        self
    }
}

impl wkt::message::Message for JwtLocation {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.JwtLocation"
    }
}

/// Defines additional types related to [JwtLocation].
pub mod jwt_location {
    #[allow(unused_imports)]
    use super::*;

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum In {
        /// Specifies HTTP header name to extract JWT token.
        Header(std::string::String),
        /// Specifies URL query parameter name to extract JWT token.
        Query(std::string::String),
        /// Specifies cookie name to extract JWT token.
        Cookie(std::string::String),
    }
}

/// Configuration for an authentication provider, including support for
/// [JSON Web Token
/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AuthProvider {
    /// The unique identifier of the auth provider. It will be referred to by
    /// `AuthRequirement.provider_id`.
    ///
    /// Example: "bookstore_auth".
    pub id: std::string::String,

    /// Identifies the principal that issued the JWT. See
    /// <https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1>
    /// Usually a URL or an email address.
    ///
    /// Example: <https://securetoken.google.com>
    /// Example: 1234567-compute@developer.gserviceaccount.com
    pub issuer: std::string::String,

    /// URL of the provider's public key set to validate signature of the JWT. See
    /// [OpenID
    /// Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
    /// Optional if the key set document:
    ///
    /// - can be retrieved from
    ///   [OpenID
    ///   Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
    ///   of the issuer.
    /// - can be inferred from the email domain of the issuer (e.g. a Google
    ///   service account).
    ///
    /// Example: <https://www.googleapis.com/oauth2/v1/certs>
    pub jwks_uri: std::string::String,

    /// The list of JWT
    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
    /// that are allowed to access. A JWT containing any of these audiences will
    /// be accepted. When this setting is absent, JWTs with audiences:
    ///
    /// - "https://[service.name]/[google.protobuf.Api.name]"
    /// - "https://[service.name]/"
    ///   will be accepted.
    ///   For example, if no audiences are in the setting, LibraryService API will
    ///   accept JWTs with the following audiences:
    ///
    /// <https://library-example.googleapis.com/google.example.library.v1.LibraryService>
    ///
    /// - <https://library-example.googleapis.com/>
    ///
    /// Example:
    ///
    /// ```norust
    /// audiences: bookstore_android.apps.googleusercontent.com,
    ///            bookstore_web.apps.googleusercontent.com
    /// ```
    pub audiences: std::string::String,

    /// Redirect URL if JWT token is required but not present or is expired.
    /// Implement authorizationUrl of securityDefinitions in OpenAPI spec.
    pub authorization_url: std::string::String,

    /// Defines the locations to extract the JWT.  For now it is only used by the
    /// Cloud Endpoints to store the OpenAPI extension [x-google-jwt-locations]
    /// (<https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-jwt-locations>)
    ///
    /// JWT locations can be one of HTTP headers, URL query parameters or
    /// cookies. The rule is that the first match wins.
    ///
    /// If not specified,  default to use following 3 locations:
    ///
    /// 1. Authorization: Bearer
    /// 1. x-goog-iap-jwt-assertion
    /// 1. access_token query parameter
    ///
    /// Default locations can be specified as followings:
    /// jwt_locations:
    ///
    /// - header: Authorization
    ///   value_prefix: "Bearer "
    /// - header: x-goog-iap-jwt-assertion
    /// - query: access_token
    pub jwt_locations: std::vec::Vec<crate::model::JwtLocation>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AuthProvider {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [id][crate::model::AuthProvider::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [issuer][crate::model::AuthProvider::issuer].
    pub fn set_issuer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.issuer = v.into();
        self
    }

    /// Sets the value of [jwks_uri][crate::model::AuthProvider::jwks_uri].
    pub fn set_jwks_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.jwks_uri = v.into();
        self
    }

    /// Sets the value of [audiences][crate::model::AuthProvider::audiences].
    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.audiences = v.into();
        self
    }

    /// Sets the value of [authorization_url][crate::model::AuthProvider::authorization_url].
    pub fn set_authorization_url<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.authorization_url = v.into();
        self
    }

    /// Sets the value of [jwt_locations][crate::model::AuthProvider::jwt_locations].
    pub fn set_jwt_locations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::JwtLocation>,
    {
        use std::iter::Iterator;
        self.jwt_locations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for AuthProvider {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.AuthProvider"
    }
}

/// OAuth scopes are a way to define data and permissions on data. For example,
/// there are scopes defined for "Read-only access to Google Calendar" and
/// "Access to Cloud Platform". Users can consent to a scope for an application,
/// giving it permission to access that data on their behalf.
///
/// OAuth scope specifications should be fairly coarse grained; a user will need
/// to see and understand the text description of what your scope means.
///
/// In most cases: use one or at most two OAuth scopes for an entire family of
/// products. If your product has multiple APIs, you should probably be sharing
/// the OAuth scope across all of those APIs.
///
/// When you need finer grained OAuth consent screens: talk with your product
/// management about how developers will use them in practice.
///
/// Please note that even though each of the canonical scopes is enough for a
/// request to be accepted and passed to the backend, a request can still fail
/// due to the backend requiring additional scopes or permissions.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OAuthRequirements {
    /// The list of publicly documented OAuth scopes that are allowed access. An
    /// OAuth token containing any of these scopes will be accepted.
    ///
    /// Example:
    ///
    /// ```norust
    ///  canonical_scopes: https://www.googleapis.com/auth/calendar,
    ///                    https://www.googleapis.com/auth/calendar.read
    /// ```
    pub canonical_scopes: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OAuthRequirements {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [canonical_scopes][crate::model::OAuthRequirements::canonical_scopes].
    pub fn set_canonical_scopes<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.canonical_scopes = v.into();
        self
    }
}

impl wkt::message::Message for OAuthRequirements {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.OAuthRequirements"
    }
}

/// User-defined authentication requirements, including support for
/// [JSON Web Token
/// (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AuthRequirement {
    /// [id][google.api.AuthProvider.id] from authentication provider.
    ///
    /// Example:
    ///
    /// ```norust
    /// provider_id: bookstore_auth
    /// ```
    ///
    /// [google.api.AuthProvider.id]: crate::model::AuthProvider::id
    pub provider_id: std::string::String,

    /// NOTE: This will be deprecated soon, once AuthProvider.audiences is
    /// implemented and accepted in all the runtime components.
    ///
    /// The list of JWT
    /// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
    /// that are allowed to access. A JWT containing any of these audiences will
    /// be accepted. When this setting is absent, only JWTs with audience
    /// "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
    /// will be accepted. For example, if no audiences are in the setting,
    /// LibraryService API will only accept JWTs with the following audience
    /// `https://library-example.googleapis.com/google.example.library.v1.LibraryService`.
    ///
    /// Example:
    ///
    /// ```norust
    /// audiences: bookstore_android.apps.googleusercontent.com,
    ///            bookstore_web.apps.googleusercontent.com
    /// ```
    ///
    /// [google.api.Service.name]: crate::model::Service::name
    /// [google.protobuf.Api.name]: wkt::Api::name
    pub audiences: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AuthRequirement {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [provider_id][crate::model::AuthRequirement::provider_id].
    pub fn set_provider_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.provider_id = v.into();
        self
    }

    /// Sets the value of [audiences][crate::model::AuthRequirement::audiences].
    pub fn set_audiences<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.audiences = v.into();
        self
    }
}

impl wkt::message::Message for AuthRequirement {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.AuthRequirement"
    }
}

/// `Backend` defines the backend configuration for a service.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Backend {
    /// A list of API backend rules that apply to individual API methods.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::BackendRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Backend {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::Backend::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::BackendRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Backend {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Backend"
    }
}

/// A backend rule provides configuration for an individual API element.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BackendRule {
    /// Selects the methods to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// The address of the API backend.
    ///
    /// The scheme is used to determine the backend protocol and security.
    /// The following schemes are accepted:
    ///
    /// SCHEME        PROTOCOL    SECURITY
    /// http://       HTTP        None
    /// https://      HTTP        TLS
    /// grpc://       gRPC        None
    /// grpcs://      gRPC        TLS
    ///
    /// It is recommended to explicitly include a scheme. Leaving out the scheme
    /// may cause constrasting behaviors across platforms.
    ///
    /// If the port is unspecified, the default is:
    ///
    /// - 80 for schemes without TLS
    /// - 443 for schemes with TLS
    ///
    /// For HTTP backends, use [protocol][google.api.BackendRule.protocol]
    /// to specify the protocol version.
    ///
    /// [google.api.BackendRule.protocol]: crate::model::BackendRule::protocol
    pub address: std::string::String,

    /// The number of seconds to wait for a response from a request. The default
    /// varies based on the request protocol and deployment environment.
    pub deadline: f64,

    /// Deprecated, do not use.
    #[deprecated]
    pub min_deadline: f64,

    /// The number of seconds to wait for the completion of a long running
    /// operation. The default is no deadline.
    pub operation_deadline: f64,

    pub path_translation: crate::model::backend_rule::PathTranslation,

    /// The protocol used for sending a request to the backend.
    /// The supported values are "http/1.1" and "h2".
    ///
    /// The default value is inferred from the scheme in the
    /// [address][google.api.BackendRule.address] field:
    ///
    /// SCHEME        PROTOCOL
    /// http://       http/1.1
    /// https://      http/1.1
    /// grpc://       h2
    /// grpcs://      h2
    ///
    /// For secure HTTP backends (https://) that support HTTP/2, set this field
    /// to "h2" for improved performance.
    ///
    /// Configuring this field to non-default values is only supported for secure
    /// HTTP backends. This field will be ignored for all other backends.
    ///
    /// See
    /// <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids>
    /// for more details on the supported values.
    ///
    /// [google.api.BackendRule.address]: crate::model::BackendRule::address
    pub protocol: std::string::String,

    /// The map between request protocol and the backend address.
    pub overrides_by_request_protocol:
        std::collections::HashMap<std::string::String, crate::model::BackendRule>,

    /// Authentication settings used by the backend.
    ///
    /// These are typically used to provide service management functionality to
    /// a backend served on a publicly-routable URL. The `authentication`
    /// details should match the authentication behavior used by the backend.
    ///
    /// For example, specifying `jwt_audience` implies that the backend expects
    /// authentication via a JWT.
    ///
    /// When authentication is unspecified, the resulting behavior is the same
    /// as `disable_auth` set to `true`.
    ///
    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
    /// JWT ID token.
    pub authentication: std::option::Option<crate::model::backend_rule::Authentication>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BackendRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::BackendRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [address][crate::model::BackendRule::address].
    pub fn set_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.address = v.into();
        self
    }

    /// Sets the value of [deadline][crate::model::BackendRule::deadline].
    pub fn set_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.deadline = v.into();
        self
    }

    /// Sets the value of [min_deadline][crate::model::BackendRule::min_deadline].
    #[deprecated]
    pub fn set_min_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.min_deadline = v.into();
        self
    }

    /// Sets the value of [operation_deadline][crate::model::BackendRule::operation_deadline].
    pub fn set_operation_deadline<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.operation_deadline = v.into();
        self
    }

    /// Sets the value of [path_translation][crate::model::BackendRule::path_translation].
    pub fn set_path_translation<
        T: std::convert::Into<crate::model::backend_rule::PathTranslation>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.path_translation = v.into();
        self
    }

    /// Sets the value of [protocol][crate::model::BackendRule::protocol].
    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.protocol = v.into();
        self
    }

    /// Sets the value of [overrides_by_request_protocol][crate::model::BackendRule::overrides_by_request_protocol].
    pub fn set_overrides_by_request_protocol<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<crate::model::BackendRule>,
    {
        use std::iter::Iterator;
        self.overrides_by_request_protocol =
            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [authentication][crate::model::BackendRule::authentication].
    ///
    /// Note that all the setters affecting `authentication` are mutually
    /// exclusive.
    pub fn set_authentication<
        T: std::convert::Into<std::option::Option<crate::model::backend_rule::Authentication>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.authentication = v.into();
        self
    }

    /// The value of [authentication][crate::model::BackendRule::authentication]
    /// if it holds a `JwtAudience`, `None` if the field is not set or
    /// holds a different branch.
    pub fn jwt_audience(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.authentication.as_ref().and_then(|v| match v {
            crate::model::backend_rule::Authentication::JwtAudience(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
    /// to hold a `JwtAudience`.
    ///
    /// Note that all the setters affecting `authentication` are
    /// mutually exclusive.
    pub fn set_jwt_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.authentication = std::option::Option::Some(
            crate::model::backend_rule::Authentication::JwtAudience(v.into()),
        );
        self
    }

    /// The value of [authentication][crate::model::BackendRule::authentication]
    /// if it holds a `DisableAuth`, `None` if the field is not set or
    /// holds a different branch.
    pub fn disable_auth(&self) -> std::option::Option<&bool> {
        #[allow(unreachable_patterns)]
        self.authentication.as_ref().and_then(|v| match v {
            crate::model::backend_rule::Authentication::DisableAuth(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [authentication][crate::model::BackendRule::authentication]
    /// to hold a `DisableAuth`.
    ///
    /// Note that all the setters affecting `authentication` are
    /// mutually exclusive.
    pub fn set_disable_auth<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.authentication = std::option::Option::Some(
            crate::model::backend_rule::Authentication::DisableAuth(v.into()),
        );
        self
    }
}

impl wkt::message::Message for BackendRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.BackendRule"
    }
}

/// Defines additional types related to [BackendRule].
pub mod backend_rule {
    #[allow(unused_imports)]
    use super::*;

    /// Path Translation specifies how to combine the backend address with the
    /// request path in order to produce the appropriate forwarding URL for the
    /// request.
    ///
    /// Path Translation is applicable only to HTTP-based backends. Backends which
    /// do not accept requests over HTTP/HTTPS should leave `path_translation`
    /// unspecified.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum PathTranslation {
        Unspecified,
        /// Use the backend address as-is, with no modification to the path. If the
        /// URL pattern contains variables, the variable names and values will be
        /// appended to the query string. If a query string parameter and a URL
        /// pattern variable have the same name, this may result in duplicate keys in
        /// the query string.
        ///
        /// # Examples
        ///
        /// Given the following operation config:
        ///
        /// ```norust
        /// Method path:        /api/company/{cid}/user/{uid}
        /// Backend address:    https://example.cloudfunctions.net/getUser
        /// ```
        ///
        /// Requests to the following request paths will call the backend at the
        /// translated path:
        ///
        /// ```norust
        /// Request path: /api/company/widgetworks/user/johndoe
        /// Translated:
        /// https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe
        ///
        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
        /// Translated:
        /// https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe
        /// ```
        ConstantAddress,
        /// The request path will be appended to the backend address.
        ///
        /// # Examples
        ///
        /// Given the following operation config:
        ///
        /// ```norust
        /// Method path:        /api/company/{cid}/user/{uid}
        /// Backend address:    https://example.appspot.com
        /// ```
        ///
        /// Requests to the following request paths will call the backend at the
        /// translated path:
        ///
        /// ```norust
        /// Request path: /api/company/widgetworks/user/johndoe
        /// Translated:
        /// https://example.appspot.com/api/company/widgetworks/user/johndoe
        ///
        /// Request path: /api/company/widgetworks/user/johndoe?timezone=EST
        /// Translated:
        /// https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST
        /// ```
        AppendPathToAddress,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [PathTranslation::value] or
        /// [PathTranslation::name].
        UnknownValue(path_translation::UnknownValue),
    }

    #[doc(hidden)]
    pub mod path_translation {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl PathTranslation {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::ConstantAddress => std::option::Option::Some(1),
                Self::AppendPathToAddress => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("PATH_TRANSLATION_UNSPECIFIED"),
                Self::ConstantAddress => std::option::Option::Some("CONSTANT_ADDRESS"),
                Self::AppendPathToAddress => std::option::Option::Some("APPEND_PATH_TO_ADDRESS"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for PathTranslation {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for PathTranslation {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for PathTranslation {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::ConstantAddress,
                2 => Self::AppendPathToAddress,
                _ => Self::UnknownValue(path_translation::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for PathTranslation {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "PATH_TRANSLATION_UNSPECIFIED" => Self::Unspecified,
                "CONSTANT_ADDRESS" => Self::ConstantAddress,
                "APPEND_PATH_TO_ADDRESS" => Self::AppendPathToAddress,
                _ => Self::UnknownValue(path_translation::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for PathTranslation {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::ConstantAddress => serializer.serialize_i32(1),
                Self::AppendPathToAddress => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for PathTranslation {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PathTranslation>::new(
                ".google.api.BackendRule.PathTranslation",
            ))
        }
    }

    /// Authentication settings used by the backend.
    ///
    /// These are typically used to provide service management functionality to
    /// a backend served on a publicly-routable URL. The `authentication`
    /// details should match the authentication behavior used by the backend.
    ///
    /// For example, specifying `jwt_audience` implies that the backend expects
    /// authentication via a JWT.
    ///
    /// When authentication is unspecified, the resulting behavior is the same
    /// as `disable_auth` set to `true`.
    ///
    /// Refer to <https://developers.google.com/identity/protocols/OpenIDConnect> for
    /// JWT ID token.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Authentication {
        /// The JWT audience is used when generating a JWT ID token for the backend.
        /// This ID token will be added in the HTTP "authorization" header, and sent
        /// to the backend.
        JwtAudience(std::string::String),
        /// When disable_auth is true, a JWT ID token won't be generated and the
        /// original "Authorization" HTTP header will be preserved. If the header is
        /// used to carry the original token and is expected by the backend, this
        /// field must be set to true to preserve the header.
        DisableAuth(bool),
    }
}

/// Billing related configuration of the service.
///
/// The following example shows how to configure monitored resources and metrics
/// for billing, `consumer_destinations` is the only supported destination and
/// the monitored resources need at least one label key
/// `cloud.googleapis.com/location` to indicate the location of the billing
/// usage, using different monitored resources between monitoring and billing is
/// recommended so they can be evolved independently:
///
/// ```norust
/// monitored_resources:
/// - type: library.googleapis.com/billing_branch
///   labels:
///   - key: cloud.googleapis.com/location
///     description: |
///       Predefined label to support billing location restriction.
///   - key: city
///     description: |
///       Custom label to define the city where the library branch is located
///       in.
///   - key: name
///     description: Custom label to define the name of the library branch.
/// metrics:
/// - name: library.googleapis.com/book/borrowed_count
///   metric_kind: DELTA
///   value_type: INT64
///   unit: "1"
/// billing:
///   consumer_destinations:
///   - monitored_resource: library.googleapis.com/billing_branch
///     metrics:
///     - library.googleapis.com/book/borrowed_count
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Billing {
    /// Billing configurations for sending metrics to the consumer project.
    /// There can be multiple consumer destinations per service, each one must have
    /// a different monitored resource type. A metric can be used in at most
    /// one consumer destination.
    pub consumer_destinations: std::vec::Vec<crate::model::billing::BillingDestination>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Billing {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [consumer_destinations][crate::model::Billing::consumer_destinations].
    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::billing::BillingDestination>,
    {
        use std::iter::Iterator;
        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Billing {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Billing"
    }
}

/// Defines additional types related to [Billing].
pub mod billing {
    #[allow(unused_imports)]
    use super::*;

    /// Configuration of a specific billing destination (Currently only support
    /// bill against consumer project).
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct BillingDestination {
        /// The monitored resource type. The type must be defined in
        /// [Service.monitored_resources][google.api.Service.monitored_resources]
        /// section.
        ///
        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
        pub monitored_resource: std::string::String,

        /// Names of the metrics to report to this billing destination.
        /// Each name must be defined in
        /// [Service.metrics][google.api.Service.metrics] section.
        ///
        /// [google.api.Service.metrics]: crate::model::Service::metrics
        pub metrics: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl BillingDestination {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [monitored_resource][crate::model::billing::BillingDestination::monitored_resource].
        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.monitored_resource = v.into();
            self
        }

        /// Sets the value of [metrics][crate::model::billing::BillingDestination::metrics].
        pub fn set_metrics<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.metrics = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for BillingDestination {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Billing.BillingDestination"
        }
    }
}

/// Required information for every language.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CommonLanguageSettings {
    /// Link to automatically generated reference documentation.  Example:
    /// <https://cloud.google.com/nodejs/docs/reference/asset/latest>
    #[deprecated]
    pub reference_docs_uri: std::string::String,

    /// The destination where API teams want this client library to be published.
    pub destinations: std::vec::Vec<crate::model::ClientLibraryDestination>,

    /// Configuration for which RPCs should be generated in the GAPIC client.
    pub selective_gapic_generation: std::option::Option<crate::model::SelectiveGapicGeneration>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CommonLanguageSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [reference_docs_uri][crate::model::CommonLanguageSettings::reference_docs_uri].
    #[deprecated]
    pub fn set_reference_docs_uri<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.reference_docs_uri = v.into();
        self
    }

    /// Sets the value of [destinations][crate::model::CommonLanguageSettings::destinations].
    pub fn set_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ClientLibraryDestination>,
    {
        use std::iter::Iterator;
        self.destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
    pub fn set_selective_gapic_generation<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
    {
        self.selective_gapic_generation = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [selective_gapic_generation][crate::model::CommonLanguageSettings::selective_gapic_generation].
    pub fn set_or_clear_selective_gapic_generation<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::SelectiveGapicGeneration>,
    {
        self.selective_gapic_generation = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CommonLanguageSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.CommonLanguageSettings"
    }
}

/// Details about how and where to publish client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ClientLibrarySettings {
    /// Version of the API to apply these settings to. This is the full protobuf
    /// package for the API, ending in the version element.
    /// Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1".
    pub version: std::string::String,

    /// Launch stage of this version of the API.
    pub launch_stage: crate::model::LaunchStage,

    /// When using transport=rest, the client request will encode enums as
    /// numbers rather than strings.
    pub rest_numeric_enums: bool,

    /// Settings for legacy Java features, supported in the Service YAML.
    pub java_settings: std::option::Option<crate::model::JavaSettings>,

    /// Settings for C++ client libraries.
    pub cpp_settings: std::option::Option<crate::model::CppSettings>,

    /// Settings for PHP client libraries.
    pub php_settings: std::option::Option<crate::model::PhpSettings>,

    /// Settings for Python client libraries.
    pub python_settings: std::option::Option<crate::model::PythonSettings>,

    /// Settings for Node client libraries.
    pub node_settings: std::option::Option<crate::model::NodeSettings>,

    /// Settings for .NET client libraries.
    pub dotnet_settings: std::option::Option<crate::model::DotnetSettings>,

    /// Settings for Ruby client libraries.
    pub ruby_settings: std::option::Option<crate::model::RubySettings>,

    /// Settings for Go client libraries.
    pub go_settings: std::option::Option<crate::model::GoSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ClientLibrarySettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [version][crate::model::ClientLibrarySettings::version].
    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version = v.into();
        self
    }

    /// Sets the value of [launch_stage][crate::model::ClientLibrarySettings::launch_stage].
    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
        mut self,
        v: T,
    ) -> Self {
        self.launch_stage = v.into();
        self
    }

    /// Sets the value of [rest_numeric_enums][crate::model::ClientLibrarySettings::rest_numeric_enums].
    pub fn set_rest_numeric_enums<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.rest_numeric_enums = v.into();
        self
    }

    /// Sets the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
    pub fn set_java_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::JavaSettings>,
    {
        self.java_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [java_settings][crate::model::ClientLibrarySettings::java_settings].
    pub fn set_or_clear_java_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::JavaSettings>,
    {
        self.java_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
    pub fn set_cpp_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CppSettings>,
    {
        self.cpp_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [cpp_settings][crate::model::ClientLibrarySettings::cpp_settings].
    pub fn set_or_clear_cpp_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CppSettings>,
    {
        self.cpp_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
    pub fn set_php_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PhpSettings>,
    {
        self.php_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [php_settings][crate::model::ClientLibrarySettings::php_settings].
    pub fn set_or_clear_php_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PhpSettings>,
    {
        self.php_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
    pub fn set_python_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PythonSettings>,
    {
        self.python_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [python_settings][crate::model::ClientLibrarySettings::python_settings].
    pub fn set_or_clear_python_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PythonSettings>,
    {
        self.python_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
    pub fn set_node_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::NodeSettings>,
    {
        self.node_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [node_settings][crate::model::ClientLibrarySettings::node_settings].
    pub fn set_or_clear_node_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::NodeSettings>,
    {
        self.node_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
    pub fn set_dotnet_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::DotnetSettings>,
    {
        self.dotnet_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [dotnet_settings][crate::model::ClientLibrarySettings::dotnet_settings].
    pub fn set_or_clear_dotnet_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::DotnetSettings>,
    {
        self.dotnet_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
    pub fn set_ruby_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::RubySettings>,
    {
        self.ruby_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [ruby_settings][crate::model::ClientLibrarySettings::ruby_settings].
    pub fn set_or_clear_ruby_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::RubySettings>,
    {
        self.ruby_settings = v.map(|x| x.into());
        self
    }

    /// Sets the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
    pub fn set_go_settings<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::GoSettings>,
    {
        self.go_settings = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [go_settings][crate::model::ClientLibrarySettings::go_settings].
    pub fn set_or_clear_go_settings<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::GoSettings>,
    {
        self.go_settings = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for ClientLibrarySettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ClientLibrarySettings"
    }
}

/// This message configures the settings for publishing [Google Cloud Client
/// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
/// generated from the service config.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Publishing {
    /// A list of API method settings, e.g. the behavior for methods that use the
    /// long-running operation pattern.
    pub method_settings: std::vec::Vec<crate::model::MethodSettings>,

    /// Link to a *public* URI where users can report issues.  Example:
    /// <https://issuetracker.google.com/issues/new?component=190865&template=1161103>
    pub new_issue_uri: std::string::String,

    /// Link to product home page.  Example:
    /// <https://cloud.google.com/asset-inventory/docs/overview>
    pub documentation_uri: std::string::String,

    /// Used as a tracking tag when collecting data about the APIs developer
    /// relations artifacts like docs, packages delivered to package managers,
    /// etc.  Example: "speech".
    pub api_short_name: std::string::String,

    /// GitHub label to apply to issues and pull requests opened for this API.
    pub github_label: std::string::String,

    /// GitHub teams to be added to CODEOWNERS in the directory in GitHub
    /// containing source code for the client libraries for this API.
    pub codeowner_github_teams: std::vec::Vec<std::string::String>,

    /// A prefix used in sample code when demarking regions to be included in
    /// documentation.
    pub doc_tag_prefix: std::string::String,

    /// For whom the client library is being published.
    pub organization: crate::model::ClientLibraryOrganization,

    /// Client library settings.  If the same version string appears multiple
    /// times in this list, then the last one wins.  Settings from earlier
    /// settings with the same version string are discarded.
    pub library_settings: std::vec::Vec<crate::model::ClientLibrarySettings>,

    /// Optional link to proto reference documentation.  Example:
    /// <https://cloud.google.com/pubsub/lite/docs/reference/rpc>
    pub proto_reference_documentation_uri: std::string::String,

    /// Optional link to REST reference documentation.  Example:
    /// <https://cloud.google.com/pubsub/lite/docs/reference/rest>
    pub rest_reference_documentation_uri: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Publishing {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [method_settings][crate::model::Publishing::method_settings].
    pub fn set_method_settings<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MethodSettings>,
    {
        use std::iter::Iterator;
        self.method_settings = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [new_issue_uri][crate::model::Publishing::new_issue_uri].
    pub fn set_new_issue_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.new_issue_uri = v.into();
        self
    }

    /// Sets the value of [documentation_uri][crate::model::Publishing::documentation_uri].
    pub fn set_documentation_uri<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.documentation_uri = v.into();
        self
    }

    /// Sets the value of [api_short_name][crate::model::Publishing::api_short_name].
    pub fn set_api_short_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_short_name = v.into();
        self
    }

    /// Sets the value of [github_label][crate::model::Publishing::github_label].
    pub fn set_github_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.github_label = v.into();
        self
    }

    /// Sets the value of [codeowner_github_teams][crate::model::Publishing::codeowner_github_teams].
    pub fn set_codeowner_github_teams<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.codeowner_github_teams = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [doc_tag_prefix][crate::model::Publishing::doc_tag_prefix].
    pub fn set_doc_tag_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.doc_tag_prefix = v.into();
        self
    }

    /// Sets the value of [organization][crate::model::Publishing::organization].
    pub fn set_organization<T: std::convert::Into<crate::model::ClientLibraryOrganization>>(
        mut self,
        v: T,
    ) -> Self {
        self.organization = v.into();
        self
    }

    /// Sets the value of [library_settings][crate::model::Publishing::library_settings].
    pub fn set_library_settings<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ClientLibrarySettings>,
    {
        use std::iter::Iterator;
        self.library_settings = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [proto_reference_documentation_uri][crate::model::Publishing::proto_reference_documentation_uri].
    pub fn set_proto_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.proto_reference_documentation_uri = v.into();
        self
    }

    /// Sets the value of [rest_reference_documentation_uri][crate::model::Publishing::rest_reference_documentation_uri].
    pub fn set_rest_reference_documentation_uri<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.rest_reference_documentation_uri = v.into();
        self
    }
}

impl wkt::message::Message for Publishing {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Publishing"
    }
}

/// Settings for Java client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct JavaSettings {
    /// The package name to use in Java. Clobbers the java_package option
    /// set in the protobuf. This should be used **only** by APIs
    /// who have already set the language_settings.java.package_name" field
    /// in gapic.yaml. API teams should use the protobuf java_package option
    /// where possible.
    ///
    /// Example of a YAML configuration::
    ///
    /// publishing:
    /// java_settings:
    /// library_package: com.google.cloud.pubsub.v1
    pub library_package: std::string::String,

    /// Configure the Java class name to use instead of the service's for its
    /// corresponding generated GAPIC client. Keys are fully-qualified
    /// service names as they appear in the protobuf (including the full
    /// the language_settings.java.interface_names" field in gapic.yaml. API
    /// teams should otherwise use the service name as it appears in the
    /// protobuf.
    ///
    /// Example of a YAML configuration::
    ///
    /// publishing:
    /// java_settings:
    /// service_class_names:
    /// - google.pubsub.v1.Publisher: TopicAdmin
    /// - google.pubsub.v1.Subscriber: SubscriptionAdmin
    pub service_class_names: std::collections::HashMap<std::string::String, std::string::String>,

    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl JavaSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [library_package][crate::model::JavaSettings::library_package].
    pub fn set_library_package<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.library_package = v.into();
        self
    }

    /// Sets the value of [service_class_names][crate::model::JavaSettings::service_class_names].
    pub fn set_service_class_names<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.service_class_names = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [common][crate::model::JavaSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::JavaSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for JavaSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.JavaSettings"
    }
}

/// Settings for C++ client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CppSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CppSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::CppSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::CppSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CppSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.CppSettings"
    }
}

/// Settings for Php client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PhpSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PhpSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::PhpSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::PhpSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for PhpSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.PhpSettings"
    }
}

/// Settings for Python client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PythonSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    /// Experimental features to be included during client library generation.
    pub experimental_features:
        std::option::Option<crate::model::python_settings::ExperimentalFeatures>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PythonSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::PythonSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::PythonSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }

    /// Sets the value of [experimental_features][crate::model::PythonSettings::experimental_features].
    pub fn set_experimental_features<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
    {
        self.experimental_features = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [experimental_features][crate::model::PythonSettings::experimental_features].
    pub fn set_or_clear_experimental_features<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::python_settings::ExperimentalFeatures>,
    {
        self.experimental_features = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for PythonSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.PythonSettings"
    }
}

/// Defines additional types related to [PythonSettings].
pub mod python_settings {
    #[allow(unused_imports)]
    use super::*;

    /// Experimental features to be included during client library generation.
    /// These fields will be deprecated once the feature graduates and is enabled
    /// by default.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ExperimentalFeatures {
        /// Enables generation of asynchronous REST clients if `rest` transport is
        /// enabled. By default, asynchronous REST clients will not be generated.
        /// This feature will be enabled by default 1 month after launching the
        /// feature in preview packages.
        pub rest_async_io_enabled: bool,

        /// Enables generation of protobuf code using new types that are more
        /// Pythonic which are included in `protobuf>=5.29.x`. This feature will be
        /// enabled by default 1 month after launching the feature in preview
        /// packages.
        pub protobuf_pythonic_types_enabled: bool,

        /// Disables generation of an unversioned Python package for this client
        /// library. This means that the module names will need to be versioned in
        /// import statements. For example `import google.cloud.library_v2` instead
        /// of `import google.cloud.library`.
        pub unversioned_package_disabled: bool,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ExperimentalFeatures {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [rest_async_io_enabled][crate::model::python_settings::ExperimentalFeatures::rest_async_io_enabled].
        pub fn set_rest_async_io_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
            self.rest_async_io_enabled = v.into();
            self
        }

        /// Sets the value of [protobuf_pythonic_types_enabled][crate::model::python_settings::ExperimentalFeatures::protobuf_pythonic_types_enabled].
        pub fn set_protobuf_pythonic_types_enabled<T: std::convert::Into<bool>>(
            mut self,
            v: T,
        ) -> Self {
            self.protobuf_pythonic_types_enabled = v.into();
            self
        }

        /// Sets the value of [unversioned_package_disabled][crate::model::python_settings::ExperimentalFeatures::unversioned_package_disabled].
        pub fn set_unversioned_package_disabled<T: std::convert::Into<bool>>(
            mut self,
            v: T,
        ) -> Self {
            self.unversioned_package_disabled = v.into();
            self
        }
    }

    impl wkt::message::Message for ExperimentalFeatures {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.PythonSettings.ExperimentalFeatures"
        }
    }
}

/// Settings for Node client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct NodeSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl NodeSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::NodeSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::NodeSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for NodeSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.NodeSettings"
    }
}

/// Settings for Dotnet client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DotnetSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    /// Map from original service names to renamed versions.
    /// This is used when the default generated types
    /// would cause a naming conflict. (Neither name is
    /// fully-qualified.)
    /// Example: Subscriber to SubscriberServiceApi.
    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,

    /// Map from full resource types to the effective short name
    /// for the resource. This is used when otherwise resource
    /// named from different services would cause naming collisions.
    /// Example entry:
    /// "datalabeling.googleapis.com/Dataset": "DataLabelingDataset"
    pub renamed_resources: std::collections::HashMap<std::string::String, std::string::String>,

    /// List of full resource types to ignore during generation.
    /// This is typically used for API-specific Location resources,
    /// which should be handled by the generator as if they were actually
    /// the common Location resources.
    /// Example entry: "documentai.googleapis.com/Location"
    pub ignored_resources: std::vec::Vec<std::string::String>,

    /// Namespaces which must be aliased in snippets due to
    /// a known (but non-generator-predictable) naming collision
    pub forced_namespace_aliases: std::vec::Vec<std::string::String>,

    /// Method signatures (in the form "service.method(signature)")
    /// which are provided separately, so shouldn't be generated.
    /// Snippets *calling* these methods are still generated, however.
    pub handwritten_signatures: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DotnetSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::DotnetSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::DotnetSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }

    /// Sets the value of [renamed_services][crate::model::DotnetSettings::renamed_services].
    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [renamed_resources][crate::model::DotnetSettings::renamed_resources].
    pub fn set_renamed_resources<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.renamed_resources = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [ignored_resources][crate::model::DotnetSettings::ignored_resources].
    pub fn set_ignored_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.ignored_resources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [forced_namespace_aliases][crate::model::DotnetSettings::forced_namespace_aliases].
    pub fn set_forced_namespace_aliases<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.forced_namespace_aliases = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [handwritten_signatures][crate::model::DotnetSettings::handwritten_signatures].
    pub fn set_handwritten_signatures<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.handwritten_signatures = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for DotnetSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.DotnetSettings"
    }
}

/// Settings for Ruby client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RubySettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RubySettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::RubySettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::RubySettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for RubySettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.RubySettings"
    }
}

/// Settings for Go client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GoSettings {
    /// Some settings.
    pub common: std::option::Option<crate::model::CommonLanguageSettings>,

    /// Map of service names to renamed services. Keys are the package relative
    /// service names and values are the name to be used for the service client
    /// and call options.
    ///
    /// publishing:
    /// go_settings:
    /// renamed_services:
    /// Publisher: TopicAdmin
    pub renamed_services: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GoSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [common][crate::model::GoSettings::common].
    pub fn set_common<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [common][crate::model::GoSettings::common].
    pub fn set_or_clear_common<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CommonLanguageSettings>,
    {
        self.common = v.map(|x| x.into());
        self
    }

    /// Sets the value of [renamed_services][crate::model::GoSettings::renamed_services].
    pub fn set_renamed_services<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.renamed_services = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for GoSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.GoSettings"
    }
}

/// Describes the generator configuration for a method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MethodSettings {
    /// The fully qualified name of the method, for which the options below apply.
    /// This is used to find the method to apply the options.
    ///
    /// Example:
    ///
    /// ```norust
    /// publishing:
    ///   method_settings:
    ///   - selector: google.storage.control.v2.StorageControl.CreateFolder
    ///     # method settings for CreateFolder...
    /// ```
    pub selector: std::string::String,

    /// Describes settings to use for long-running operations when generating
    /// API methods for RPCs. Complements RPCs that use the annotations in
    /// google/longrunning/operations.proto.
    ///
    /// Example of a YAML configuration::
    ///
    /// ```norust
    /// publishing:
    ///   method_settings:
    ///   - selector: google.cloud.speech.v2.Speech.BatchRecognize
    ///     long_running:
    ///       initial_poll_delay: 60s # 1 minute
    ///       poll_delay_multiplier: 1.5
    ///       max_poll_delay: 360s # 6 minutes
    ///       total_poll_timeout: 54000s # 90 minutes
    /// ```
    pub long_running: std::option::Option<crate::model::method_settings::LongRunning>,

    /// List of top-level fields of the request message, that should be
    /// automatically populated by the client libraries based on their
    /// (google.api.field_info).format. Currently supported format: UUID4.
    ///
    /// Example of a YAML configuration:
    ///
    /// ```norust
    /// publishing:
    ///   method_settings:
    ///   - selector: google.example.v1.ExampleService.CreateExample
    ///     auto_populated_fields:
    ///     - request_id
    /// ```
    pub auto_populated_fields: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MethodSettings {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::MethodSettings::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [long_running][crate::model::MethodSettings::long_running].
    pub fn set_long_running<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::method_settings::LongRunning>,
    {
        self.long_running = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [long_running][crate::model::MethodSettings::long_running].
    pub fn set_or_clear_long_running<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::method_settings::LongRunning>,
    {
        self.long_running = v.map(|x| x.into());
        self
    }

    /// Sets the value of [auto_populated_fields][crate::model::MethodSettings::auto_populated_fields].
    pub fn set_auto_populated_fields<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.auto_populated_fields = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for MethodSettings {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MethodSettings"
    }
}

/// Defines additional types related to [MethodSettings].
pub mod method_settings {
    #[allow(unused_imports)]
    use super::*;

    /// Describes settings to use when generating API methods that use the
    /// long-running operation pattern.
    /// All default values below are from those used in the client library
    /// generators (e.g.
    /// [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)).
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct LongRunning {
        /// Initial delay after which the first poll request will be made.
        /// Default value: 5 seconds.
        pub initial_poll_delay: std::option::Option<wkt::Duration>,

        /// Multiplier to gradually increase delay between subsequent polls until it
        /// reaches max_poll_delay.
        /// Default value: 1.5.
        pub poll_delay_multiplier: f32,

        /// Maximum time between two subsequent poll requests.
        /// Default value: 45 seconds.
        pub max_poll_delay: std::option::Option<wkt::Duration>,

        /// Total polling timeout.
        /// Default value: 5 minutes.
        pub total_poll_timeout: std::option::Option<wkt::Duration>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl LongRunning {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
        pub fn set_initial_poll_delay<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.initial_poll_delay = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [initial_poll_delay][crate::model::method_settings::LongRunning::initial_poll_delay].
        pub fn set_or_clear_initial_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.initial_poll_delay = v.map(|x| x.into());
            self
        }

        /// Sets the value of [poll_delay_multiplier][crate::model::method_settings::LongRunning::poll_delay_multiplier].
        pub fn set_poll_delay_multiplier<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
            self.poll_delay_multiplier = v.into();
            self
        }

        /// Sets the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
        pub fn set_max_poll_delay<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.max_poll_delay = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [max_poll_delay][crate::model::method_settings::LongRunning::max_poll_delay].
        pub fn set_or_clear_max_poll_delay<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.max_poll_delay = v.map(|x| x.into());
            self
        }

        /// Sets the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
        pub fn set_total_poll_timeout<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.total_poll_timeout = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [total_poll_timeout][crate::model::method_settings::LongRunning::total_poll_timeout].
        pub fn set_or_clear_total_poll_timeout<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.total_poll_timeout = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for LongRunning {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.MethodSettings.LongRunning"
        }
    }
}

/// This message is used to configure the generation of a subset of the RPCs in
/// a service for client libraries.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SelectiveGapicGeneration {
    /// An allowlist of the fully qualified names of RPCs that should be included
    /// on public client surfaces.
    pub methods: std::vec::Vec<std::string::String>,

    /// Setting this to true indicates to the client generators that methods
    /// that would be excluded from the generation should instead be generated
    /// in a way that indicates these methods should not be consumed by
    /// end users. How this is expressed is up to individual language
    /// implementations to decide. Some examples may be: added annotations,
    /// obfuscated identifiers, or other language idiomatic patterns.
    pub generate_omitted_as_internal: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SelectiveGapicGeneration {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [methods][crate::model::SelectiveGapicGeneration::methods].
    pub fn set_methods<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.methods = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [generate_omitted_as_internal][crate::model::SelectiveGapicGeneration::generate_omitted_as_internal].
    pub fn set_generate_omitted_as_internal<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.generate_omitted_as_internal = v.into();
        self
    }
}

impl wkt::message::Message for SelectiveGapicGeneration {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.SelectiveGapicGeneration"
    }
}

/// Output generated from semantically comparing two versions of a service
/// configuration.
///
/// Includes detailed information about a field that have changed with
/// applicable advice about potential consequences for the change, such as
/// backwards-incompatibility.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ConfigChange {
    /// Object hierarchy path to the change, with levels separated by a '.'
    /// character. For repeated fields, an applicable unique identifier field is
    /// used for the index (usually selector, name, or id). For maps, the term
    /// 'key' is used. If the field has no unique identifier, the numeric index
    /// is used.
    /// Examples:
    ///
    /// - visibility.rules[selector=="google.LibraryService.ListBooks"].restriction
    /// - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value
    /// - logging.producer_destinations[0]
    pub element: std::string::String,

    /// Value of the changed object in the old Service configuration,
    /// in JSON format. This field will not be populated if ChangeType == ADDED.
    pub old_value: std::string::String,

    /// Value of the changed object in the new Service configuration,
    /// in JSON format. This field will not be populated if ChangeType == REMOVED.
    pub new_value: std::string::String,

    /// The type for this change, either ADDED, REMOVED, or MODIFIED.
    pub change_type: crate::model::ChangeType,

    /// Collection of advice provided for this change, useful for determining the
    /// possible impact of this change.
    pub advices: std::vec::Vec<crate::model::Advice>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ConfigChange {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [element][crate::model::ConfigChange::element].
    pub fn set_element<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.element = v.into();
        self
    }

    /// Sets the value of [old_value][crate::model::ConfigChange::old_value].
    pub fn set_old_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.old_value = v.into();
        self
    }

    /// Sets the value of [new_value][crate::model::ConfigChange::new_value].
    pub fn set_new_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.new_value = v.into();
        self
    }

    /// Sets the value of [change_type][crate::model::ConfigChange::change_type].
    pub fn set_change_type<T: std::convert::Into<crate::model::ChangeType>>(
        mut self,
        v: T,
    ) -> Self {
        self.change_type = v.into();
        self
    }

    /// Sets the value of [advices][crate::model::ConfigChange::advices].
    pub fn set_advices<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Advice>,
    {
        use std::iter::Iterator;
        self.advices = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ConfigChange {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ConfigChange"
    }
}

/// Generated advice about this change, used for providing more
/// information about how a change will affect the existing service.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Advice {
    /// Useful description for why this advice was applied and what actions should
    /// be taken to mitigate any implied risks.
    pub description: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Advice {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [description][crate::model::Advice::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }
}

impl wkt::message::Message for Advice {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Advice"
    }
}

/// A descriptor for defining project properties for a service. One service may
/// have many consumer projects, and the service may want to behave differently
/// depending on some properties on the project. For example, a project may be
/// associated with a school, or a business, or a government agency, a business
/// type property on the project may affect how a service responds to the client.
/// This descriptor defines which properties are allowed to be set on a project.
///
/// Example:
///
/// ```norust
/// project_properties:
///   properties:
///   - name: NO_WATERMARK
///     type: BOOL
///     description: Allows usage of the API without watermarks.
///   - name: EXTENDED_TILE_CACHE_PERIOD
///     type: INT64
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ProjectProperties {
    /// List of per consumer project-specific properties.
    pub properties: std::vec::Vec<crate::model::Property>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ProjectProperties {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [properties][crate::model::ProjectProperties::properties].
    pub fn set_properties<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Property>,
    {
        use std::iter::Iterator;
        self.properties = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ProjectProperties {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ProjectProperties"
    }
}

/// Defines project properties.
///
/// API services can define properties that can be assigned to consumer projects
/// so that backends can perform response customization without having to make
/// additional calls or maintain additional storage. For example, Maps API
/// defines properties that controls map tile cache period, or whether to embed a
/// watermark in a result.
///
/// These values can be set via API producer console. Only API providers can
/// define and set these properties.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Property {
    /// The name of the property (a.k.a key).
    pub name: std::string::String,

    /// The type of this property.
    pub r#type: crate::model::property::PropertyType,

    /// The description of the property
    pub description: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Property {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Property::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::Property::type].
    pub fn set_type<T: std::convert::Into<crate::model::property::PropertyType>>(
        mut self,
        v: T,
    ) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [description][crate::model::Property::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }
}

impl wkt::message::Message for Property {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Property"
    }
}

/// Defines additional types related to [Property].
pub mod property {
    #[allow(unused_imports)]
    use super::*;

    /// Supported data type of the property values
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum PropertyType {
        /// The type is unspecified, and will result in an error.
        Unspecified,
        /// The type is `int64`.
        Int64,
        /// The type is `bool`.
        Bool,
        /// The type is `string`.
        String,
        /// The type is 'double'.
        Double,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [PropertyType::value] or
        /// [PropertyType::name].
        UnknownValue(property_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod property_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl PropertyType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Int64 => std::option::Option::Some(1),
                Self::Bool => std::option::Option::Some(2),
                Self::String => std::option::Option::Some(3),
                Self::Double => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
                Self::Int64 => std::option::Option::Some("INT64"),
                Self::Bool => std::option::Option::Some("BOOL"),
                Self::String => std::option::Option::Some("STRING"),
                Self::Double => std::option::Option::Some("DOUBLE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for PropertyType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for PropertyType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for PropertyType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Int64,
                2 => Self::Bool,
                3 => Self::String,
                4 => Self::Double,
                _ => Self::UnknownValue(property_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for PropertyType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "UNSPECIFIED" => Self::Unspecified,
                "INT64" => Self::Int64,
                "BOOL" => Self::Bool,
                "STRING" => Self::String,
                "DOUBLE" => Self::Double,
                _ => Self::UnknownValue(property_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for PropertyType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Int64 => serializer.serialize_i32(1),
                Self::Bool => serializer.serialize_i32(2),
                Self::String => serializer.serialize_i32(3),
                Self::Double => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for PropertyType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PropertyType>::new(
                ".google.api.Property.PropertyType",
            ))
        }
    }
}

/// `Context` defines which contexts an API requests.
///
/// Example:
///
/// ```norust
/// context:
///   rules:
///   - selector: "*"
///     requested:
///     - google.rpc.context.ProjectContext
///     - google.rpc.context.OriginContext
/// ```
///
/// The above specifies that all methods in the API request
/// `google.rpc.context.ProjectContext` and
/// `google.rpc.context.OriginContext`.
///
/// Available context types are defined in package
/// `google.rpc.context`.
///
/// This also provides mechanism to allowlist any protobuf message extension that
/// can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
/// “x-goog-ext-<extension_id>-jspb” format. For example, list any service
/// specific protobuf types that can appear in grpc metadata as follows in your
/// yaml file:
///
/// Example:
///
/// ```norust
/// context:
///   rules:
///    - selector: "google.example.library.v1.LibraryService.CreateBook"
///      allowed_request_extensions:
///      - google.foo.v1.NewExtension
///      allowed_response_extensions:
///      - google.foo.v1.NewExtension
/// ```
///
/// You can also specify extension ID instead of fully qualified extension name
/// here.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Context {
    /// A list of RPC context rules that apply to individual API methods.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::ContextRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Context {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::Context::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ContextRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Context {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Context"
    }
}

/// A context rule provides information about the context for an individual API
/// element.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ContextRule {
    /// Selects the methods to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// A list of full type names of requested contexts, only the requested context
    /// will be made available to the backend.
    pub requested: std::vec::Vec<std::string::String>,

    /// A list of full type names of provided contexts. It is used to support
    /// propagating HTTP headers and ETags from the response extension.
    pub provided: std::vec::Vec<std::string::String>,

    /// A list of full type names or extension IDs of extensions allowed in grpc
    /// side channel from client to backend.
    pub allowed_request_extensions: std::vec::Vec<std::string::String>,

    /// A list of full type names or extension IDs of extensions allowed in grpc
    /// side channel from backend to client.
    pub allowed_response_extensions: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ContextRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::ContextRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [requested][crate::model::ContextRule::requested].
    pub fn set_requested<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.requested = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [provided][crate::model::ContextRule::provided].
    pub fn set_provided<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.provided = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [allowed_request_extensions][crate::model::ContextRule::allowed_request_extensions].
    pub fn set_allowed_request_extensions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.allowed_request_extensions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [allowed_response_extensions][crate::model::ContextRule::allowed_response_extensions].
    pub fn set_allowed_response_extensions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.allowed_response_extensions = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ContextRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ContextRule"
    }
}

/// Selects and configures the service controller used by the service.
///
/// Example:
///
/// ```norust
/// control:
///   environment: servicecontrol.googleapis.com
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Control {
    /// The service controller environment to use. If empty, no control plane
    /// feature (like quota and billing) will be enabled. The recommended value for
    /// most services is servicecontrol.googleapis.com
    pub environment: std::string::String,

    /// Defines policies applying to the API methods of the service.
    pub method_policies: std::vec::Vec<crate::model::MethodPolicy>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Control {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [environment][crate::model::Control::environment].
    pub fn set_environment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.environment = v.into();
        self
    }

    /// Sets the value of [method_policies][crate::model::Control::method_policies].
    pub fn set_method_policies<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MethodPolicy>,
    {
        use std::iter::Iterator;
        self.method_policies = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Control {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Control"
    }
}

/// `Distribution` contains summary statistics for a population of values. It
/// optionally contains a histogram representing the distribution of those values
/// across a set of buckets.
///
/// The summary statistics are the count, mean, sum of the squared deviation from
/// the mean, the minimum, and the maximum of the set of population of values.
/// The histogram is based on a sequence of buckets and gives a count of values
/// that fall into each bucket. The boundaries of the buckets are given either
/// explicitly or by formulas for buckets of fixed or exponentially increasing
/// widths.
///
/// Although it is not forbidden, it is generally a bad idea to include
/// non-finite values (infinities or NaNs) in the population of values, as this
/// will render the `mean` and `sum_of_squared_deviation` fields meaningless.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Distribution {
    /// The number of values in the population. Must be non-negative. This value
    /// must equal the sum of the values in `bucket_counts` if a histogram is
    /// provided.
    pub count: i64,

    /// The arithmetic mean of the values in the population. If `count` is zero
    /// then this field must be zero.
    pub mean: f64,

    /// The sum of squared deviations from the mean of the values in the
    /// population. For values x_i this is:
    ///
    /// ```norust
    /// Sum[i=1..n]((x_i - mean)^2)
    /// ```
    ///
    /// Knuth, "The Art of Computer Programming", Vol. 2, page 232, 3rd edition
    /// describes Welford's method for accumulating this sum in one pass.
    ///
    /// If `count` is zero then this field must be zero.
    pub sum_of_squared_deviation: f64,

    /// If specified, contains the range of the population values. The field
    /// must not be present if the `count` is zero.
    pub range: std::option::Option<crate::model::distribution::Range>,

    /// Defines the histogram bucket boundaries. If the distribution does not
    /// contain a histogram, then omit this field.
    pub bucket_options: std::option::Option<crate::model::distribution::BucketOptions>,

    /// The number of values in each bucket of the histogram, as described in
    /// `bucket_options`. If the distribution does not have a histogram, then omit
    /// this field. If there is a histogram, then the sum of the values in
    /// `bucket_counts` must equal the value in the `count` field of the
    /// distribution.
    ///
    /// If present, `bucket_counts` should contain N values, where N is the number
    /// of buckets specified in `bucket_options`. If you supply fewer than N
    /// values, the remaining values are assumed to be 0.
    ///
    /// The order of the values in `bucket_counts` follows the bucket numbering
    /// schemes described for the three bucket types. The first value must be the
    /// count for the underflow bucket (number 0). The next N-2 values are the
    /// counts for the finite buckets (number 1 through N-2). The N'th value in
    /// `bucket_counts` is the count for the overflow bucket (number N-1).
    pub bucket_counts: std::vec::Vec<i64>,

    /// Must be in increasing order of `value` field.
    pub exemplars: std::vec::Vec<crate::model::distribution::Exemplar>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Distribution {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [count][crate::model::Distribution::count].
    pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.count = v.into();
        self
    }

    /// Sets the value of [mean][crate::model::Distribution::mean].
    pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.mean = v.into();
        self
    }

    /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
    pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.sum_of_squared_deviation = v.into();
        self
    }

    /// Sets the value of [range][crate::model::Distribution::range].
    pub fn set_range<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::distribution::Range>,
    {
        self.range = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [range][crate::model::Distribution::range].
    pub fn set_or_clear_range<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::distribution::Range>,
    {
        self.range = v.map(|x| x.into());
        self
    }

    /// Sets the value of [bucket_options][crate::model::Distribution::bucket_options].
    pub fn set_bucket_options<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::distribution::BucketOptions>,
    {
        self.bucket_options = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [bucket_options][crate::model::Distribution::bucket_options].
    pub fn set_or_clear_bucket_options<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::distribution::BucketOptions>,
    {
        self.bucket_options = v.map(|x| x.into());
        self
    }

    /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
    pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<i64>,
    {
        use std::iter::Iterator;
        self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
    pub fn set_exemplars<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::distribution::Exemplar>,
    {
        use std::iter::Iterator;
        self.exemplars = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Distribution {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Distribution"
    }
}

/// Defines additional types related to [Distribution].
pub mod distribution {
    #[allow(unused_imports)]
    use super::*;

    /// The range of the population values.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Range {
        /// The minimum of the population values.
        pub min: f64,

        /// The maximum of the population values.
        pub max: f64,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Range {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [min][crate::model::distribution::Range::min].
        pub fn set_min<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
            self.min = v.into();
            self
        }

        /// Sets the value of [max][crate::model::distribution::Range::max].
        pub fn set_max<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
            self.max = v.into();
            self
        }
    }

    impl wkt::message::Message for Range {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Distribution.Range"
        }
    }

    /// `BucketOptions` describes the bucket boundaries used to create a histogram
    /// for the distribution. The buckets can be in a linear sequence, an
    /// exponential sequence, or each bucket can be specified explicitly.
    /// `BucketOptions` does not include the number of values in each bucket.
    ///
    /// A bucket has an inclusive lower bound and exclusive upper bound for the
    /// values that are counted for that bucket. The upper bound of a bucket must
    /// be strictly greater than the lower bound. The sequence of N buckets for a
    /// distribution consists of an underflow bucket (number 0), zero or more
    /// finite buckets (number 1 through N - 2) and an overflow bucket (number N -
    /// 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the
    /// same as the upper bound of bucket i - 1. The buckets span the whole range
    /// of finite values: lower bound of the underflow bucket is -infinity and the
    /// upper bound of the overflow bucket is +infinity. The finite buckets are
    /// so-called because both bounds are finite.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct BucketOptions {
        /// Exactly one of these three fields must be set.
        pub options: std::option::Option<crate::model::distribution::bucket_options::Options>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl BucketOptions {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [options][crate::model::distribution::BucketOptions::options].
        ///
        /// Note that all the setters affecting `options` are mutually
        /// exclusive.
        pub fn set_options<
            T: std::convert::Into<
                    std::option::Option<crate::model::distribution::bucket_options::Options>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.options = v.into();
            self
        }

        /// The value of [options][crate::model::distribution::BucketOptions::options]
        /// if it holds a `LinearBuckets`, `None` if the field is not set or
        /// holds a different branch.
        pub fn linear_buckets(
            &self,
        ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::bucket_options::Linear>>
        {
            #[allow(unreachable_patterns)]
            self.options.as_ref().and_then(|v| match v {
                crate::model::distribution::bucket_options::Options::LinearBuckets(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
        /// to hold a `LinearBuckets`.
        ///
        /// Note that all the setters affecting `options` are
        /// mutually exclusive.
        pub fn set_linear_buckets<
            T: std::convert::Into<std::boxed::Box<crate::model::distribution::bucket_options::Linear>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.options = std::option::Option::Some(
                crate::model::distribution::bucket_options::Options::LinearBuckets(v.into()),
            );
            self
        }

        /// The value of [options][crate::model::distribution::BucketOptions::options]
        /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
        /// holds a different branch.
        pub fn exponential_buckets(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
        > {
            #[allow(unreachable_patterns)]
            self.options.as_ref().and_then(|v| match v {
                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
        /// to hold a `ExponentialBuckets`.
        ///
        /// Note that all the setters affecting `options` are
        /// mutually exclusive.
        pub fn set_exponential_buckets<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.options = std::option::Option::Some(
                crate::model::distribution::bucket_options::Options::ExponentialBuckets(v.into()),
            );
            self
        }

        /// The value of [options][crate::model::distribution::BucketOptions::options]
        /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
        /// holds a different branch.
        pub fn explicit_buckets(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
        > {
            #[allow(unreachable_patterns)]
            self.options.as_ref().and_then(|v| match v {
                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [options][crate::model::distribution::BucketOptions::options]
        /// to hold a `ExplicitBuckets`.
        ///
        /// Note that all the setters affecting `options` are
        /// mutually exclusive.
        pub fn set_explicit_buckets<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::distribution::bucket_options::Explicit>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.options = std::option::Option::Some(
                crate::model::distribution::bucket_options::Options::ExplicitBuckets(v.into()),
            );
            self
        }
    }

    impl wkt::message::Message for BucketOptions {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Distribution.BucketOptions"
        }
    }

    /// Defines additional types related to [BucketOptions].
    pub mod bucket_options {
        #[allow(unused_imports)]
        use super::*;

        /// Specifies a linear sequence of buckets that all have the same width
        /// (except overflow and underflow). Each bucket represents a constant
        /// absolute uncertainty on the specific value in the bucket.
        ///
        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
        /// following boundaries:
        ///
        /// Upper bound (0 <= i < N-1):     offset + (width * i).
        ///
        /// Lower bound (1 <= i < N):       offset + (width * (i - 1)).
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Linear {
            /// Must be greater than 0.
            pub num_finite_buckets: i32,

            /// Must be greater than 0.
            pub width: f64,

            /// Lower bound of the first bucket.
            pub offset: f64,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Linear {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Linear::num_finite_buckets].
            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
                self.num_finite_buckets = v.into();
                self
            }

            /// Sets the value of [width][crate::model::distribution::bucket_options::Linear::width].
            pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
                self.width = v.into();
                self
            }

            /// Sets the value of [offset][crate::model::distribution::bucket_options::Linear::offset].
            pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
                self.offset = v.into();
                self
            }
        }

        impl wkt::message::Message for Linear {
            fn typename() -> &'static str {
                "type.googleapis.com/google.api.Distribution.BucketOptions.Linear"
            }
        }

        /// Specifies an exponential sequence of buckets that have a width that is
        /// proportional to the value of the lower bound. Each bucket represents a
        /// constant relative uncertainty on a specific value in the bucket.
        ///
        /// There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
        /// following boundaries:
        ///
        /// Upper bound (0 <= i < N-1):     scale * (growth_factor ^ i).
        ///
        /// Lower bound (1 <= i < N):       scale * (growth_factor ^ (i - 1)).
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Exponential {
            /// Must be greater than 0.
            pub num_finite_buckets: i32,

            /// Must be greater than 1.
            pub growth_factor: f64,

            /// Must be greater than 0.
            pub scale: f64,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Exponential {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [num_finite_buckets][crate::model::distribution::bucket_options::Exponential::num_finite_buckets].
            pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
                self.num_finite_buckets = v.into();
                self
            }

            /// Sets the value of [growth_factor][crate::model::distribution::bucket_options::Exponential::growth_factor].
            pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
                self.growth_factor = v.into();
                self
            }

            /// Sets the value of [scale][crate::model::distribution::bucket_options::Exponential::scale].
            pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
                self.scale = v.into();
                self
            }
        }

        impl wkt::message::Message for Exponential {
            fn typename() -> &'static str {
                "type.googleapis.com/google.api.Distribution.BucketOptions.Exponential"
            }
        }

        /// Specifies a set of buckets with arbitrary widths.
        ///
        /// There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following
        /// boundaries:
        ///
        /// Upper bound (0 <= i < N-1):     bounds[i]
        /// Lower bound (1 <= i < N);       bounds[i - 1]
        ///
        /// The `bounds` field must contain at least one element. If `bounds` has
        /// only one element, then there are no finite buckets, and that single
        /// element is the common boundary of the overflow and underflow buckets.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Explicit {
            /// The values must be monotonically increasing.
            pub bounds: std::vec::Vec<f64>,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Explicit {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [bounds][crate::model::distribution::bucket_options::Explicit::bounds].
            pub fn set_bounds<T, V>(mut self, v: T) -> Self
            where
                T: std::iter::IntoIterator<Item = V>,
                V: std::convert::Into<f64>,
            {
                use std::iter::Iterator;
                self.bounds = v.into_iter().map(|i| i.into()).collect();
                self
            }
        }

        impl wkt::message::Message for Explicit {
            fn typename() -> &'static str {
                "type.googleapis.com/google.api.Distribution.BucketOptions.Explicit"
            }
        }

        /// Exactly one of these three fields must be set.
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum Options {
            /// The linear bucket.
            LinearBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Linear>),
            /// The exponential buckets.
            ExponentialBuckets(
                std::boxed::Box<crate::model::distribution::bucket_options::Exponential>,
            ),
            /// The explicit buckets.
            ExplicitBuckets(std::boxed::Box<crate::model::distribution::bucket_options::Explicit>),
        }
    }

    /// Exemplars are example points that may be used to annotate aggregated
    /// distribution values. They are metadata that gives information about a
    /// particular value added to a Distribution bucket, such as a trace ID that
    /// was active when a value was added. They may contain further information,
    /// such as a example values and timestamps, origin, etc.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Exemplar {
        /// Value of the exemplar point. This value determines to which bucket the
        /// exemplar belongs.
        pub value: f64,

        /// The observation (sampling) time of the above value.
        pub timestamp: std::option::Option<wkt::Timestamp>,

        /// Contextual information about the example value. Examples are:
        ///
        /// Trace: type.googleapis.com/google.monitoring.v3.SpanContext
        ///
        /// Literal string: type.googleapis.com/google.protobuf.StringValue
        ///
        /// Labels dropped during aggregation:
        /// type.googleapis.com/google.monitoring.v3.DroppedLabels
        ///
        /// There may be only a single attachment of any given message type in a
        /// single exemplar, and this is enforced by the system.
        pub attachments: std::vec::Vec<wkt::Any>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Exemplar {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [value][crate::model::distribution::Exemplar::value].
        pub fn set_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
            self.value = v.into();
            self
        }

        /// Sets the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
        pub fn set_timestamp<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.timestamp = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [timestamp][crate::model::distribution::Exemplar::timestamp].
        pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.timestamp = v.map(|x| x.into());
            self
        }

        /// Sets the value of [attachments][crate::model::distribution::Exemplar::attachments].
        pub fn set_attachments<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<wkt::Any>,
        {
            use std::iter::Iterator;
            self.attachments = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for Exemplar {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Distribution.Exemplar"
        }
    }
}

/// `Documentation` provides the information for describing a service.
///
/// Example:
///
/// Documentation is provided in markdown syntax. In addition to
/// standard markdown features, definition lists, tables and fenced
/// code blocks are supported. Section headers can be provided and are
/// interpreted relative to the section nesting of the context where
/// a documentation fragment is embedded.
///
/// Documentation from the IDL is merged with documentation defined
/// via the config at normalization time, where documentation provided
/// by config rules overrides IDL provided.
///
/// A number of constructs specific to the API platform are supported
/// in documentation text.
///
/// In order to reference a proto element, the following
/// notation can be used:
///
/// To override the display text used for the link, this can be used:
///
/// Text can be excluded from doc using the following notation:
///
/// A few directives are available in documentation. Note that
/// directives must appear on a single line to be properly
/// identified. The `include` directive includes a markdown file from
/// an external source:
///
/// The `resource_for` directive marks a message to be the resource of
/// a collection in REST view. If it is not specified, tools attempt
/// to infer the resource from the operations in a collection:
///
/// The directive `suppress_warning` does not directly affect documentation
/// and is documented together with service config validation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Documentation {
    /// A short description of what the service does. The summary must be plain
    /// text. It becomes the overview of the service displayed in Google Cloud
    /// Console.
    /// NOTE: This field is equivalent to the standard field `description`.
    pub summary: std::string::String,

    /// The top level pages for the documentation set.
    pub pages: std::vec::Vec<crate::model::Page>,

    /// A list of documentation rules that apply to individual API elements.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::DocumentationRule>,

    /// The URL to the root of documentation.
    pub documentation_root_url: std::string::String,

    /// Specifies the service root url if the default one (the service name
    /// from the yaml file) is not suitable. This can be seen in any fully
    /// specified service urls as well as sections that show a base that other
    /// urls are relative to.
    pub service_root_url: std::string::String,

    /// Declares a single overview page. For example:
    ///
    /// This is a shortcut for the following declaration (using pages style):
    ///
    /// Note: you cannot specify both `overview` field and `pages` field.
    pub overview: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Documentation {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [summary][crate::model::Documentation::summary].
    pub fn set_summary<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.summary = v.into();
        self
    }

    /// Sets the value of [pages][crate::model::Documentation::pages].
    pub fn set_pages<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Page>,
    {
        use std::iter::Iterator;
        self.pages = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [rules][crate::model::Documentation::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::DocumentationRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [documentation_root_url][crate::model::Documentation::documentation_root_url].
    pub fn set_documentation_root_url<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.documentation_root_url = v.into();
        self
    }

    /// Sets the value of [service_root_url][crate::model::Documentation::service_root_url].
    pub fn set_service_root_url<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_root_url = v.into();
        self
    }

    /// Sets the value of [overview][crate::model::Documentation::overview].
    pub fn set_overview<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.overview = v.into();
        self
    }
}

impl wkt::message::Message for Documentation {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Documentation"
    }
}

/// A documentation rule provides information about individual API elements.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DocumentationRule {
    /// The selector is a comma-separated list of patterns for any element such as
    /// a method, a field, an enum value. Each pattern is a qualified name of the
    /// element which may end in "*", indicating a wildcard. Wildcards are only
    /// allowed at the end and for a whole component of the qualified name,
    /// i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". A wildcard will match
    /// one or more components. To specify a default for all applicable elements,
    /// the whole pattern "*" is used.
    pub selector: std::string::String,

    /// Description of the selected proto element (e.g. a message, a method, a
    /// 'service' definition, or a field). Defaults to leading & trailing comments
    /// taken from the proto source definition of the proto element.
    pub description: std::string::String,

    /// Deprecation description of the selected element(s). It can be provided if
    /// an element is marked as `deprecated`.
    pub deprecation_description: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DocumentationRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::DocumentationRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [description][crate::model::DocumentationRule::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [deprecation_description][crate::model::DocumentationRule::deprecation_description].
    pub fn set_deprecation_description<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.deprecation_description = v.into();
        self
    }
}

impl wkt::message::Message for DocumentationRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.DocumentationRule"
    }
}

/// Represents a documentation page. A page can contain subpages to represent
/// nested documentation set structure.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Page {
    /// The name of the page. It will be used as an identity of the page to
    /// generate URI of the page, text of the link to this page in navigation,
    /// etc. The full page name (start from the root page name to this page
    /// concatenated with `.`) can be used as reference to the page in your
    /// documentation. For example:
    ///
    /// You can reference `Java` page using Markdown reference link syntax:
    /// `[Java][Tutorial.Java]`.
    pub name: std::string::String,

    /// The Markdown content of the page. You can use ```(== include {path}
    /// ==)``` to include content from a Markdown file. The content can be used
    /// to produce the documentation page such as HTML format page.
    pub content: std::string::String,

    /// Subpages of this page. The order of subpages specified here will be
    /// honored in the generated docset.
    pub subpages: std::vec::Vec<crate::model::Page>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Page {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Page::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [content][crate::model::Page::content].
    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.content = v.into();
        self
    }

    /// Sets the value of [subpages][crate::model::Page::subpages].
    pub fn set_subpages<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Page>,
    {
        use std::iter::Iterator;
        self.subpages = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Page {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Page"
    }
}

/// `Endpoint` describes a network address of a service that serves a set of
/// APIs. It is commonly known as a service endpoint. A service may expose
/// any number of service endpoints, and all service endpoints share the same
/// service definition, such as quota limits and monitoring metrics.
///
/// Example:
///
/// ```norust
/// type: google.api.Service
/// name: library-example.googleapis.com
/// endpoints:
///   # Declares network address `https://library-example.googleapis.com`
///   # for service `library-example.googleapis.com`. The `https` scheme
///   # is implicit for all service endpoints. Other schemes may be
///   # supported in the future.
/// - name: library-example.googleapis.com
///   allow_cors: false
/// - name: content-staging-library-example.googleapis.com
///   # Allows HTTP OPTIONS calls to be passed to the API frontend, for it
///   # to decide whether the subsequent cross-origin request is allowed
///   # to proceed.
///   allow_cors: true
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Endpoint {
    /// The canonical name of this endpoint.
    pub name: std::string::String,

    /// Aliases for this endpoint, these will be served by the same UrlMap as the
    /// parent endpoint, and will be provisioned in the GCP stack for the Regional
    /// Endpoints.
    pub aliases: std::vec::Vec<std::string::String>,

    /// The specification of an Internet routable address of API frontend that will
    /// handle requests to this [API
    /// Endpoint](https://cloud.google.com/apis/design/glossary). It should be
    /// either a valid IPv4 address or a fully-qualified domain name. For example,
    /// "8.8.8.8" or "myservice.appspot.com".
    pub target: std::string::String,

    /// Allowing
    /// [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka
    /// cross-domain traffic, would allow the backends served from this endpoint to
    /// receive and respond to HTTP OPTIONS requests. The response will be used by
    /// the browser to determine whether the subsequent cross-origin request is
    /// allowed to proceed.
    pub allow_cors: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Endpoint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Endpoint::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [aliases][crate::model::Endpoint::aliases].
    pub fn set_aliases<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.aliases = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [target][crate::model::Endpoint::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [allow_cors][crate::model::Endpoint::allow_cors].
    pub fn set_allow_cors<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.allow_cors = v.into();
        self
    }
}

impl wkt::message::Message for Endpoint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Endpoint"
    }
}

/// Rich semantic information of an API field beyond basic typing.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FieldInfo {
    /// The standard format of a field value. This does not explicitly configure
    /// any API consumer, just documents the API's format for the field it is
    /// applied to.
    pub format: crate::model::field_info::Format,

    /// The type(s) that the annotated, generic field may represent.
    ///
    /// Currently, this must only be used on fields of type `google.protobuf.Any`.
    /// Supporting other generic types may be considered in the future.
    pub referenced_types: std::vec::Vec<crate::model::TypeReference>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl FieldInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [format][crate::model::FieldInfo::format].
    pub fn set_format<T: std::convert::Into<crate::model::field_info::Format>>(
        mut self,
        v: T,
    ) -> Self {
        self.format = v.into();
        self
    }

    /// Sets the value of [referenced_types][crate::model::FieldInfo::referenced_types].
    pub fn set_referenced_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::TypeReference>,
    {
        use std::iter::Iterator;
        self.referenced_types = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for FieldInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.FieldInfo"
    }
}

/// Defines additional types related to [FieldInfo].
pub mod field_info {
    #[allow(unused_imports)]
    use super::*;

    /// The standard format of a field value. The supported formats are all backed
    /// by either an RFC defined by the IETF or a Google-defined AIP.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Format {
        /// Default, unspecified value.
        Unspecified,
        /// Universally Unique Identifier, version 4, value as defined by
        /// <https://datatracker.ietf.org/doc/html/rfc4122>. The value may be
        /// normalized to entirely lowercase letters. For example, the value
        /// `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to
        /// `f47ac10b-58cc-0372-8567-0e02b2c3d479`.
        Uuid4,
        /// Internet Protocol v4 value as defined by [RFC
        /// 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be
        /// condensed, with leading zeros in each octet stripped. For example,
        /// `001.022.233.040` would be condensed to `1.22.233.40`.
        Ipv4,
        /// Internet Protocol v6 value as defined by [RFC
        /// 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be
        /// normalized to entirely lowercase letters with zeros compressed, following
        /// [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example,
        /// the value `2001:0DB8:0::0` would be normalized to `2001:db8::`.
        Ipv6,
        /// An IP address in either v4 or v6 format as described by the individual
        /// values defined herein. See the comments on the IPV4 and IPV6 types for
        /// allowed normalizations of each.
        Ipv4OrIpv6,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Format::value] or
        /// [Format::name].
        UnknownValue(format::UnknownValue),
    }

    #[doc(hidden)]
    pub mod format {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Format {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Uuid4 => std::option::Option::Some(1),
                Self::Ipv4 => std::option::Option::Some(2),
                Self::Ipv6 => std::option::Option::Some(3),
                Self::Ipv4OrIpv6 => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("FORMAT_UNSPECIFIED"),
                Self::Uuid4 => std::option::Option::Some("UUID4"),
                Self::Ipv4 => std::option::Option::Some("IPV4"),
                Self::Ipv6 => std::option::Option::Some("IPV6"),
                Self::Ipv4OrIpv6 => std::option::Option::Some("IPV4_OR_IPV6"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Format {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Format {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Format {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Uuid4,
                2 => Self::Ipv4,
                3 => Self::Ipv6,
                4 => Self::Ipv4OrIpv6,
                _ => Self::UnknownValue(format::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Format {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "FORMAT_UNSPECIFIED" => Self::Unspecified,
                "UUID4" => Self::Uuid4,
                "IPV4" => Self::Ipv4,
                "IPV6" => Self::Ipv6,
                "IPV4_OR_IPV6" => Self::Ipv4OrIpv6,
                _ => Self::UnknownValue(format::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Format {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Uuid4 => serializer.serialize_i32(1),
                Self::Ipv4 => serializer.serialize_i32(2),
                Self::Ipv6 => serializer.serialize_i32(3),
                Self::Ipv4OrIpv6 => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Format {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Format>::new(
                ".google.api.FieldInfo.Format",
            ))
        }
    }
}

/// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo].
///
/// [google.api.FieldInfo]: crate::model::FieldInfo
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TypeReference {
    /// The name of the type that the annotated, generic field may represent.
    /// If the type is in the same protobuf package, the value can be the simple
    /// message name e.g., `"MyMessage"`. Otherwise, the value must be the
    /// fully-qualified message name e.g., `"google.library.v1.Book"`.
    ///
    /// If the type(s) are unknown to the service (e.g. the field accepts generic
    /// user input), use the wildcard `"*"` to denote this behavior.
    ///
    /// See [AIP-202](https://google.aip.dev/202#type-references) for more details.
    pub type_name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl TypeReference {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [type_name][crate::model::TypeReference::type_name].
    pub fn set_type_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.type_name = v.into();
        self
    }
}

impl wkt::message::Message for TypeReference {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.TypeReference"
    }
}

/// Defines the HTTP configuration for an API service. It contains a list of
/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
/// to one or more HTTP REST API methods.
///
/// [google.api.HttpRule]: crate::model::HttpRule
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Http {
    /// A list of HTTP configuration rules that apply to individual API methods.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::HttpRule>,

    /// When set to true, URL path parameters will be fully URI-decoded except in
    /// cases of single segment matches in reserved expansion, where "%2F" will be
    /// left encoded.
    ///
    /// The default behavior is to not decode RFC 6570 reserved characters in multi
    /// segment matches.
    pub fully_decode_reserved_expansion: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Http {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::Http::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::HttpRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [fully_decode_reserved_expansion][crate::model::Http::fully_decode_reserved_expansion].
    pub fn set_fully_decode_reserved_expansion<T: std::convert::Into<bool>>(
        mut self,
        v: T,
    ) -> Self {
        self.fully_decode_reserved_expansion = v.into();
        self
    }
}

impl wkt::message::Message for Http {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Http"
    }
}

/// gRPC Transcoding
///
/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
/// more HTTP REST endpoints. It allows developers to build a single API service
/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
/// APIs](https://github.com/googleapis/googleapis),
/// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC
/// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),
/// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature
/// and use it for large scale production services.
///
/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
/// how different portions of the gRPC request message are mapped to the URL
/// path, URL query parameters, and HTTP request body. It also controls how the
/// gRPC response message is mapped to the HTTP response body. `HttpRule` is
/// typically specified as an `google.api.http` annotation on the gRPC method.
///
/// Each mapping specifies a URL path template and an HTTP method. The path
/// template may refer to one or more fields in the gRPC request message, as long
/// as each field is a non-repeated field with a primitive (non-message) type.
/// The path template controls how fields of the request message are mapped to
/// the URL path.
///
/// Example:
///
/// ```norust
/// service Messaging {
///   rpc GetMessage(GetMessageRequest) returns (Message) {
///     option (google.api.http) = {
///         get: "/v1/{name=messages/*}"
///     };
///   }
/// }
/// message GetMessageRequest {
///   string name = 1; // Mapped to URL path.
/// }
/// message Message {
///   string text = 1; // The resource content.
/// }
/// ```
///
/// This enables an HTTP REST to gRPC mapping as below:
///
/// - HTTP: `GET /v1/messages/123456`
/// - gRPC: `GetMessage(name: "messages/123456")`
///
/// Any fields in the request message which are not bound by the path template
/// automatically become HTTP query parameters if there is no HTTP request body.
/// For example:
///
/// ```norust
/// service Messaging {
///   rpc GetMessage(GetMessageRequest) returns (Message) {
///     option (google.api.http) = {
///         get:"/v1/messages/{message_id}"
///     };
///   }
/// }
/// message GetMessageRequest {
///   message SubMessage {
///     string subfield = 1;
///   }
///   string message_id = 1; // Mapped to URL path.
///   int64 revision = 2;    // Mapped to URL query parameter `revision`.
///   SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`.
/// }
/// ```
///
/// This enables a HTTP JSON to RPC mapping as below:
///
/// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo`
/// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub:
///   SubMessage(subfield: "foo"))`
///
/// Note that fields which are mapped to URL query parameters must have a
/// primitive type or a repeated primitive type or a non-repeated message type.
/// In the case of a repeated type, the parameter can be repeated in the URL
/// as `...?param=A&param=B`. In the case of a message type, each field of the
/// message is mapped to a separate parameter, such as
/// `...?foo.a=A&foo.b=B&foo.c=C`.
///
/// For HTTP methods that allow a request body, the `body` field
/// specifies the mapping. Consider a REST update method on the
/// message resource collection:
///
/// ```norust
/// service Messaging {
///   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
///     option (google.api.http) = {
///       patch: "/v1/messages/{message_id}"
///       body: "message"
///     };
///   }
/// }
/// message UpdateMessageRequest {
///   string message_id = 1; // mapped to the URL
///   Message message = 2;   // mapped to the body
/// }
/// ```
///
/// The following HTTP JSON to RPC mapping is enabled, where the
/// representation of the JSON in the request body is determined by
/// protos JSON encoding:
///
/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
/// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
///
/// The special name `*` can be used in the body mapping to define that
/// every field not bound by the path template should be mapped to the
/// request body.  This enables the following alternative definition of
/// the update method:
///
/// ```norust
/// service Messaging {
///   rpc UpdateMessage(Message) returns (Message) {
///     option (google.api.http) = {
///       patch: "/v1/messages/{message_id}"
///       body: "*"
///     };
///   }
/// }
/// message Message {
///   string message_id = 1;
///   string text = 2;
/// }
/// ```
///
/// The following HTTP JSON to RPC mapping is enabled:
///
/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }`
/// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")`
///
/// Note that when using `*` in the body mapping, it is not possible to
/// have HTTP parameters, as all fields not bound by the path end in
/// the body. This makes this option more rarely used in practice when
/// defining REST APIs. The common usage of `*` is in custom methods
/// which don't use the URL at all for transferring data.
///
/// It is possible to define multiple HTTP methods for one RPC by using
/// the `additional_bindings` option. Example:
///
/// ```norust
/// service Messaging {
///   rpc GetMessage(GetMessageRequest) returns (Message) {
///     option (google.api.http) = {
///       get: "/v1/messages/{message_id}"
///       additional_bindings {
///         get: "/v1/users/{user_id}/messages/{message_id}"
///       }
///     };
///   }
/// }
/// message GetMessageRequest {
///   string message_id = 1;
///   string user_id = 2;
/// }
/// ```
///
/// This enables the following two alternative HTTP JSON to RPC mappings:
///
/// - HTTP: `GET /v1/messages/123456`
///
/// - gRPC: `GetMessage(message_id: "123456")`
///
/// - HTTP: `GET /v1/users/me/messages/123456`
///
/// - gRPC: `GetMessage(user_id: "me" message_id: "123456")`
///
///
/// Rules for HTTP mapping
///
/// 1. Leaf request fields (recursive expansion nested messages in the request
///    message) are classified into three categories:
///    - Fields referred by the path template. They are passed via the URL path.
///    - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
///      are passed via the HTTP
///      request body.
///    - All other fields are passed via the URL query parameters, and the
///      parameter name is the field path in the request message. A repeated
///      field can be represented as multiple query parameters under the same
///      name.
/// 1. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
///    query parameter, all fields
///    are passed via URL path and HTTP request body.
/// 1. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
///    request body, all
///    fields are passed via URL path and URL query parameters.
///
/// Path template syntax
///
/// ```norust
/// Template = "/" Segments [ Verb ] ;
/// Segments = Segment { "/" Segment } ;
/// Segment  = "*" | "**" | LITERAL | Variable ;
/// Variable = "{" FieldPath [ "=" Segments ] "}" ;
/// FieldPath = IDENT { "." IDENT } ;
/// Verb     = ":" LITERAL ;
/// ```
///
/// The syntax `*` matches a single URL path segment. The syntax `**` matches
/// zero or more URL path segments, which must be the last part of the URL path
/// except the `Verb`.
///
/// The syntax `Variable` matches part of the URL path as specified by its
/// template. A variable template must not contain other variables. If a variable
/// matches a single path segment, its template may be omitted, e.g. `{var}`
/// is equivalent to `{var=*}`.
///
/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
/// contains any reserved character, such characters should be percent-encoded
/// before the matching.
///
/// If a variable contains exactly one path segment, such as `"{var}"` or
/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
/// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The
/// server side does the reverse decoding. Such variables show up in the
/// [Discovery
/// Document](https://developers.google.com/discovery/v1/reference/apis) as
/// `{var}`.
///
/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
/// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.
/// The server side does the reverse decoding, except "%2F" and "%2f" are left
/// unchanged. Such variables show up in the
/// [Discovery
/// Document](https://developers.google.com/discovery/v1/reference/apis) as
/// `{+var}`.
///
/// Using gRPC API Service Configuration
///
/// gRPC API Service Configuration (service config) is a configuration language
/// for configuring a gRPC service to become a user-facing product. The
/// service config is simply the YAML representation of the `google.api.Service`
/// proto message.
///
/// As an alternative to annotating your proto file, you can configure gRPC
/// transcoding in your service config YAML files. You do this by specifying a
/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
/// effect as the proto annotation. This can be particularly useful if you
/// have a proto that is reused in multiple services. Note that any transcoding
/// specified in the service config will override any matching transcoding
/// configuration in the proto.
///
/// The following example selects a gRPC method and applies an `HttpRule` to it:
///
/// ```norust
/// http:
///   rules:
///     - selector: example.v1.Messaging.GetMessage
///       get: /v1/messages/{message_id}/{sub.subfield}
/// ```
///
/// Special notes
///
/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
/// proto to JSON conversion must follow the [proto3
/// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).
///
/// While the single segment variable follows the semantics of
/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String
/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
/// does not expand special characters like `?` and `#`, which would lead
/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
/// for multi segment variables.
///
/// The path variables **must not** refer to any repeated or mapped field,
/// because client libraries are not capable of handling such variable expansion.
///
/// The path variables **must not** capture the leading "/" character. The reason
/// is that the most common use case "{var}" does not capture the leading "/"
/// character. For consistency, all path variables must share the same behavior.
///
/// Repeated message fields must not be mapped to URL query parameters, because
/// no client library can support such complicated mapping.
///
/// If an API needs to use a JSON array for request or response body, it can map
/// the request or response body to a repeated field. However, some gRPC
/// Transcoding implementations may not support this feature.
///
/// [google.api.HttpRule.body]: crate::model::HttpRule::body
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct HttpRule {
    /// Selects a method to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// The name of the request field whose value is mapped to the HTTP request
    /// body, or `*` for mapping all request fields not captured by the path
    /// pattern to the HTTP body, or omitted for not having any HTTP request body.
    ///
    /// NOTE: the referred field must be present at the top-level of the request
    /// message type.
    pub body: std::string::String,

    /// Optional. The name of the response field whose value is mapped to the HTTP
    /// response body. When omitted, the entire response message will be used
    /// as the HTTP response body.
    ///
    /// NOTE: The referred field must be present at the top-level of the response
    /// message type.
    pub response_body: std::string::String,

    /// Additional HTTP bindings for the selector. Nested bindings must
    /// not contain an `additional_bindings` field themselves (that is,
    /// the nesting may only be one level deep).
    pub additional_bindings: std::vec::Vec<crate::model::HttpRule>,

    /// Determines the URL pattern is matched by this rules. This pattern can be
    /// used with any of the {get|put|post|delete|patch} methods. A custom method
    /// can be defined using the 'custom' field.
    pub pattern: std::option::Option<crate::model::http_rule::Pattern>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl HttpRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::HttpRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [body][crate::model::HttpRule::body].
    pub fn set_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.body = v.into();
        self
    }

    /// Sets the value of [response_body][crate::model::HttpRule::response_body].
    pub fn set_response_body<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.response_body = v.into();
        self
    }

    /// Sets the value of [additional_bindings][crate::model::HttpRule::additional_bindings].
    pub fn set_additional_bindings<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::HttpRule>,
    {
        use std::iter::Iterator;
        self.additional_bindings = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern].
    ///
    /// Note that all the setters affecting `pattern` are mutually
    /// exclusive.
    pub fn set_pattern<
        T: std::convert::Into<std::option::Option<crate::model::http_rule::Pattern>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.pattern = v.into();
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Get`, `None` if the field is not set or
    /// holds a different branch.
    pub fn get(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Get(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Get`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_get<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Get(v.into()));
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Put`, `None` if the field is not set or
    /// holds a different branch.
    pub fn put(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Put(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Put`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_put<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Put(v.into()));
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Post`, `None` if the field is not set or
    /// holds a different branch.
    pub fn post(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Post(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Post`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_post<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Post(v.into()));
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Delete`, `None` if the field is not set or
    /// holds a different branch.
    pub fn delete(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Delete(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Delete`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_delete<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.pattern =
            std::option::Option::Some(crate::model::http_rule::Pattern::Delete(v.into()));
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Patch`, `None` if the field is not set or
    /// holds a different branch.
    pub fn patch(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Patch(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Patch`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_patch<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.pattern = std::option::Option::Some(crate::model::http_rule::Pattern::Patch(v.into()));
        self
    }

    /// The value of [pattern][crate::model::HttpRule::pattern]
    /// if it holds a `Custom`, `None` if the field is not set or
    /// holds a different branch.
    pub fn custom(&self) -> std::option::Option<&std::boxed::Box<crate::model::CustomHttpPattern>> {
        #[allow(unreachable_patterns)]
        self.pattern.as_ref().and_then(|v| match v {
            crate::model::http_rule::Pattern::Custom(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [pattern][crate::model::HttpRule::pattern]
    /// to hold a `Custom`.
    ///
    /// Note that all the setters affecting `pattern` are
    /// mutually exclusive.
    pub fn set_custom<T: std::convert::Into<std::boxed::Box<crate::model::CustomHttpPattern>>>(
        mut self,
        v: T,
    ) -> Self {
        self.pattern =
            std::option::Option::Some(crate::model::http_rule::Pattern::Custom(v.into()));
        self
    }
}

impl wkt::message::Message for HttpRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.HttpRule"
    }
}

/// Defines additional types related to [HttpRule].
pub mod http_rule {
    #[allow(unused_imports)]
    use super::*;

    /// Determines the URL pattern is matched by this rules. This pattern can be
    /// used with any of the {get|put|post|delete|patch} methods. A custom method
    /// can be defined using the 'custom' field.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Pattern {
        /// Maps to HTTP GET. Used for listing and getting information about
        /// resources.
        Get(std::string::String),
        /// Maps to HTTP PUT. Used for replacing a resource.
        Put(std::string::String),
        /// Maps to HTTP POST. Used for creating a resource or performing an action.
        Post(std::string::String),
        /// Maps to HTTP DELETE. Used for deleting a resource.
        Delete(std::string::String),
        /// Maps to HTTP PATCH. Used for updating a resource.
        Patch(std::string::String),
        /// The custom pattern is used for specifying an HTTP method that is not
        /// included in the `pattern` field, such as HEAD, or "*" to leave the
        /// HTTP method unspecified for this rule. The wild-card rule is useful
        /// for services that provide content to Web (HTML) clients.
        Custom(std::boxed::Box<crate::model::CustomHttpPattern>),
    }
}

/// A custom pattern is used for defining custom HTTP verb.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CustomHttpPattern {
    /// The name of this custom HTTP verb.
    pub kind: std::string::String,

    /// The path matched by this custom verb.
    pub path: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CustomHttpPattern {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [kind][crate::model::CustomHttpPattern::kind].
    pub fn set_kind<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kind = v.into();
        self
    }

    /// Sets the value of [path][crate::model::CustomHttpPattern::path].
    pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.path = v.into();
        self
    }
}

impl wkt::message::Message for CustomHttpPattern {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.CustomHttpPattern"
    }
}

/// Message that represents an arbitrary HTTP body. It should only be used for
/// payload formats that can't be represented as JSON, such as raw binary or
/// an HTML page.
///
/// This message can be used both in streaming and non-streaming API methods in
/// the request as well as the response.
///
/// It can be used as a top-level request field, which is convenient if one
/// wants to extract parameters from either the URL or HTTP template into the
/// request fields and also want access to the raw HTTP body.
///
/// Example:
///
/// ```norust
/// message GetResourceRequest {
///   // A unique request id.
///   string request_id = 1;
///
///   // The raw HTTP body is bound to this field.
///   google.api.HttpBody http_body = 2;
///
/// }
///
/// service ResourceService {
///   rpc GetResource(GetResourceRequest)
///     returns (google.api.HttpBody);
///   rpc UpdateResource(google.api.HttpBody)
///     returns (google.protobuf.Empty);
///
/// }
/// ```
///
/// Example with streaming methods:
///
/// ```norust
/// service CaldavService {
///   rpc GetCalendar(stream google.api.HttpBody)
///     returns (stream google.api.HttpBody);
///   rpc UpdateCalendar(stream google.api.HttpBody)
///     returns (stream google.api.HttpBody);
///
/// }
/// ```
///
/// Use of this type only changes how the request and response bodies are
/// handled, all other features will continue to work unchanged.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct HttpBody {
    /// The HTTP Content-Type header value specifying the content type of the body.
    pub content_type: std::string::String,

    /// The HTTP request/response body as raw binary.
    pub data: ::bytes::Bytes,

    /// Application specific response metadata. Must be set in the first response
    /// for streaming APIs.
    pub extensions: std::vec::Vec<wkt::Any>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl HttpBody {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [content_type][crate::model::HttpBody::content_type].
    pub fn set_content_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.content_type = v.into();
        self
    }

    /// Sets the value of [data][crate::model::HttpBody::data].
    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.data = v.into();
        self
    }

    /// Sets the value of [extensions][crate::model::HttpBody::extensions].
    pub fn set_extensions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Any>,
    {
        use std::iter::Iterator;
        self.extensions = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for HttpBody {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.HttpBody"
    }
}

/// A description of a label.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct LabelDescriptor {
    /// The label key.
    pub key: std::string::String,

    /// The type of data that can be assigned to the label.
    pub value_type: crate::model::label_descriptor::ValueType,

    /// A human-readable description for the label.
    pub description: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl LabelDescriptor {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [key][crate::model::LabelDescriptor::key].
    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.key = v.into();
        self
    }

    /// Sets the value of [value_type][crate::model::LabelDescriptor::value_type].
    pub fn set_value_type<T: std::convert::Into<crate::model::label_descriptor::ValueType>>(
        mut self,
        v: T,
    ) -> Self {
        self.value_type = v.into();
        self
    }

    /// Sets the value of [description][crate::model::LabelDescriptor::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }
}

impl wkt::message::Message for LabelDescriptor {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.LabelDescriptor"
    }
}

/// Defines additional types related to [LabelDescriptor].
pub mod label_descriptor {
    #[allow(unused_imports)]
    use super::*;

    /// Value types that can be used as label values.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ValueType {
        /// A variable-length string. This is the default.
        String,
        /// Boolean; true or false.
        Bool,
        /// A 64-bit signed integer.
        Int64,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [ValueType::value] or
        /// [ValueType::name].
        UnknownValue(value_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod value_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl ValueType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::String => std::option::Option::Some(0),
                Self::Bool => std::option::Option::Some(1),
                Self::Int64 => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::String => std::option::Option::Some("STRING"),
                Self::Bool => std::option::Option::Some("BOOL"),
                Self::Int64 => std::option::Option::Some("INT64"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for ValueType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for ValueType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for ValueType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::String,
                1 => Self::Bool,
                2 => Self::Int64,
                _ => Self::UnknownValue(value_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for ValueType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STRING" => Self::String,
                "BOOL" => Self::Bool,
                "INT64" => Self::Int64,
                _ => Self::UnknownValue(value_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for ValueType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::String => serializer.serialize_i32(0),
                Self::Bool => serializer.serialize_i32(1),
                Self::Int64 => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for ValueType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
                ".google.api.LabelDescriptor.ValueType",
            ))
        }
    }
}

/// A description of a log type. Example in YAML format:
///
/// ```norust
/// - name: library.googleapis.com/activity_history
///   description: The history of borrowing and returning library items.
///   display_name: Activity
///   labels:
///   - key: /customer_id
///     description: Identifier of a library customer
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct LogDescriptor {
    /// The name of the log. It must be less than 512 characters long and can
    /// include the following characters: upper- and lower-case alphanumeric
    /// characters [A-Za-z0-9], and punctuation characters including
    /// slash, underscore, hyphen, period [/_-.].
    pub name: std::string::String,

    /// The set of labels that are available to describe a specific log entry.
    /// Runtime requests that contain labels not specified here are
    /// considered invalid.
    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,

    /// A human-readable description of this log. This information appears in
    /// the documentation and can contain details.
    pub description: std::string::String,

    /// The human-readable name for this log. This information appears on
    /// the user interface and should be concise.
    pub display_name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl LogDescriptor {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::LogDescriptor::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::LogDescriptor::labels].
    pub fn set_labels<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::LabelDescriptor>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [description][crate::model::LogDescriptor::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::LogDescriptor::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }
}

impl wkt::message::Message for LogDescriptor {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.LogDescriptor"
    }
}

/// Logging configuration of the service.
///
/// The following example shows how to configure logs to be sent to the
/// producer and consumer projects. In the example, the `activity_history`
/// log is sent to both the producer and consumer projects, whereas the
/// `purchase_history` log is only sent to the producer project.
///
/// ```norust
/// monitored_resources:
/// - type: library.googleapis.com/branch
///   labels:
///   - key: /city
///     description: The city where the library branch is located in.
///   - key: /name
///     description: The name of the branch.
/// logs:
/// - name: activity_history
///   labels:
///   - key: /customer_id
/// - name: purchase_history
/// logging:
///   producer_destinations:
///   - monitored_resource: library.googleapis.com/branch
///     logs:
///     - activity_history
///     - purchase_history
///   consumer_destinations:
///   - monitored_resource: library.googleapis.com/branch
///     logs:
///     - activity_history
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Logging {
    /// Logging configurations for sending logs to the producer project.
    /// There can be multiple producer destinations, each one must have a
    /// different monitored resource type. A log can be used in at most
    /// one producer destination.
    pub producer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,

    /// Logging configurations for sending logs to the consumer project.
    /// There can be multiple consumer destinations, each one must have a
    /// different monitored resource type. A log can be used in at most
    /// one consumer destination.
    pub consumer_destinations: std::vec::Vec<crate::model::logging::LoggingDestination>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Logging {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [producer_destinations][crate::model::Logging::producer_destinations].
    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::logging::LoggingDestination>,
    {
        use std::iter::Iterator;
        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [consumer_destinations][crate::model::Logging::consumer_destinations].
    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::logging::LoggingDestination>,
    {
        use std::iter::Iterator;
        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Logging {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Logging"
    }
}

/// Defines additional types related to [Logging].
pub mod logging {
    #[allow(unused_imports)]
    use super::*;

    /// Configuration of a specific logging destination (the producer project
    /// or the consumer project).
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct LoggingDestination {
        /// The monitored resource type. The type must be defined in the
        /// [Service.monitored_resources][google.api.Service.monitored_resources]
        /// section.
        ///
        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
        pub monitored_resource: std::string::String,

        /// Names of the logs to be sent to this destination. Each name must
        /// be defined in the [Service.logs][google.api.Service.logs] section. If the
        /// log name is not a domain scoped name, it will be automatically prefixed
        /// with the service name followed by "/".
        ///
        /// [google.api.Service.logs]: crate::model::Service::logs
        pub logs: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl LoggingDestination {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [monitored_resource][crate::model::logging::LoggingDestination::monitored_resource].
        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.monitored_resource = v.into();
            self
        }

        /// Sets the value of [logs][crate::model::logging::LoggingDestination::logs].
        pub fn set_logs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.logs = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for LoggingDestination {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Logging.LoggingDestination"
        }
    }
}

/// Defines a metric type and its schema. Once a metric descriptor is created,
/// deleting or altering it stops data collection and makes the metric type's
/// existing data unusable.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MetricDescriptor {
    /// The resource name of the metric descriptor.
    pub name: std::string::String,

    /// The metric type, including its DNS name prefix. The type is not
    /// URL-encoded. All user-defined metric types have the DNS name
    /// `custom.googleapis.com` or `external.googleapis.com`. Metric types should
    /// use a natural hierarchical grouping. For example:
    ///
    /// ```norust
    /// "custom.googleapis.com/invoice/paid/amount"
    /// "external.googleapis.com/prometheus/up"
    /// "appengine.googleapis.com/http/server/response_latencies"
    /// ```
    pub r#type: std::string::String,

    /// The set of labels that can be used to describe a specific
    /// instance of this metric type. For example, the
    /// `appengine.googleapis.com/http/server/response_latencies` metric
    /// type has a label for the HTTP response code, `response_code`, so
    /// you can look at latencies for successful responses or just
    /// for responses that failed.
    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,

    /// Whether the metric records instantaneous values, changes to a value, etc.
    /// Some combinations of `metric_kind` and `value_type` might not be supported.
    pub metric_kind: crate::model::metric_descriptor::MetricKind,

    /// Whether the measurement is an integer, a floating-point number, etc.
    /// Some combinations of `metric_kind` and `value_type` might not be supported.
    pub value_type: crate::model::metric_descriptor::ValueType,

    /// The units in which the metric value is reported. It is only applicable
    /// if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit`
    /// defines the representation of the stored metric values.
    ///
    /// Different systems might scale the values to be more easily displayed (so a
    /// value of `0.02kBy` _might_ be displayed as `20By`, and a value of
    /// `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is
    /// `kBy`, then the value of the metric is always in thousands of bytes, no
    /// matter how it might be displayed.
    ///
    /// If you want a custom metric to record the exact number of CPU-seconds used
    /// by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is
    /// `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005
    /// CPU-seconds, then the value is written as `12005`.
    ///
    /// Alternatively, if you want a custom metric to record data in a more
    /// granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is
    /// `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`),
    /// or use `Kis{CPU}` and write `11.723` (which is `12005/1024`).
    ///
    /// The supported units are a subset of [The Unified Code for Units of
    /// Measure](https://unitsofmeasure.org/ucum.html) standard:
    ///
    /// **Basic units (UNIT)**
    ///
    /// * `bit`   bit
    /// * `By`    byte
    /// * `s`     second
    /// * `min`   minute
    /// * `h`     hour
    /// * `d`     day
    /// * `1`     dimensionless
    ///
    /// **Prefixes (PREFIX)**
    ///
    /// * `k`     kilo    (10^3)
    ///
    /// * `M`     mega    (10^6)
    ///
    /// * `G`     giga    (10^9)
    ///
    /// * `T`     tera    (10^12)
    ///
    /// * `P`     peta    (10^15)
    ///
    /// * `E`     exa     (10^18)
    ///
    /// * `Z`     zetta   (10^21)
    ///
    /// * `Y`     yotta   (10^24)
    ///
    /// * `m`     milli   (10^-3)
    ///
    /// * `u`     micro   (10^-6)
    ///
    /// * `n`     nano    (10^-9)
    ///
    /// * `p`     pico    (10^-12)
    ///
    /// * `f`     femto   (10^-15)
    ///
    /// * `a`     atto    (10^-18)
    ///
    /// * `z`     zepto   (10^-21)
    ///
    /// * `y`     yocto   (10^-24)
    ///
    /// * `Ki`    kibi    (2^10)
    ///
    /// * `Mi`    mebi    (2^20)
    ///
    /// * `Gi`    gibi    (2^30)
    ///
    /// * `Ti`    tebi    (2^40)
    ///
    /// * `Pi`    pebi    (2^50)
    ///
    ///
    /// **Grammar**
    ///
    /// The grammar also includes these connectors:
    ///
    /// * `/`    division or ratio (as an infix operator). For examples,
    ///   `kBy/{email}` or `MiBy/10ms` (although you should almost never
    ///   have `/s` in a metric `unit`; rates should always be computed at
    ///   query time from the underlying cumulative or delta value).
    /// * `.`    multiplication or composition (as an infix operator). For
    ///   examples, `GBy.d` or `k{watt}.h`.
    ///
    /// The grammar for a unit is as follows:
    ///
    /// ```norust
    /// Expression = Component { "." Component } { "/" Component } ;
    ///
    /// Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ]
    ///           | Annotation
    ///           | "1"
    ///           ;
    ///
    /// Annotation = "{" NAME "}" ;
    /// ```
    ///
    /// Notes:
    ///
    /// * `Annotation` is just a comment if it follows a `UNIT`. If the annotation
    ///   is used alone, then the unit is equivalent to `1`. For examples,
    ///   `{request}/s == 1/s`, `By{transmitted}/s == By/s`.
    /// * `NAME` is a sequence of non-blank printable ASCII characters not
    ///   containing `{` or `}`.
    /// * `1` represents a unitary [dimensionless
    ///   unit](https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such
    ///   as in `1/s`. It is typically used when none of the basic units are
    ///   appropriate. For example, "new users per day" can be represented as
    ///   `1/d` or `{new-users}/d` (and a metric value `5` would mean "5 new
    ///   users). Alternatively, "thousands of page views per day" would be
    ///   represented as `1000/d` or `k1/d` or `k{page_views}/d` (and a metric
    ///   value of `5.3` would mean "5300 page views per day").
    /// * `%` represents dimensionless value of 1/100, and annotates values giving
    ///   a percentage (so the metric values are typically in the range of 0..100,
    ///   and a metric value `3` means "3 percent").
    /// * `10^2.%` indicates a metric contains a ratio, typically in the range
    ///   0..1, that will be multiplied by 100 and displayed as a percentage
    ///   (so a metric value `0.03` means "3 percent").
    pub unit: std::string::String,

    /// A detailed description of the metric, which can be used in documentation.
    pub description: std::string::String,

    /// A concise name for the metric, which can be displayed in user interfaces.
    /// Use sentence case without an ending period, for example "Request count".
    /// This field is optional but it is recommended to be set for any metrics
    /// associated with user-visible concepts, such as Quota.
    pub display_name: std::string::String,

    /// Optional. Metadata which can be used to guide usage of the metric.
    pub metadata: std::option::Option<crate::model::metric_descriptor::MetricDescriptorMetadata>,

    /// Optional. The launch stage of the metric definition.
    pub launch_stage: crate::model::LaunchStage,

    /// Read-only. If present, then a [time
    /// series][google.monitoring.v3.TimeSeries], which is identified partially by
    /// a metric type and a
    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor], that
    /// is associated with this metric type can only be associated with one of the
    /// monitored resource types listed here.
    ///
    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
    pub monitored_resource_types: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MetricDescriptor {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::MetricDescriptor::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::MetricDescriptor::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::MetricDescriptor::labels].
    pub fn set_labels<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::LabelDescriptor>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [metric_kind][crate::model::MetricDescriptor::metric_kind].
    pub fn set_metric_kind<T: std::convert::Into<crate::model::metric_descriptor::MetricKind>>(
        mut self,
        v: T,
    ) -> Self {
        self.metric_kind = v.into();
        self
    }

    /// Sets the value of [value_type][crate::model::MetricDescriptor::value_type].
    pub fn set_value_type<T: std::convert::Into<crate::model::metric_descriptor::ValueType>>(
        mut self,
        v: T,
    ) -> Self {
        self.value_type = v.into();
        self
    }

    /// Sets the value of [unit][crate::model::MetricDescriptor::unit].
    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.unit = v.into();
        self
    }

    /// Sets the value of [description][crate::model::MetricDescriptor::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::MetricDescriptor::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [metadata][crate::model::MetricDescriptor::metadata].
    pub fn set_metadata<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
    {
        self.metadata = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [metadata][crate::model::MetricDescriptor::metadata].
    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::metric_descriptor::MetricDescriptorMetadata>,
    {
        self.metadata = v.map(|x| x.into());
        self
    }

    /// Sets the value of [launch_stage][crate::model::MetricDescriptor::launch_stage].
    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
        mut self,
        v: T,
    ) -> Self {
        self.launch_stage = v.into();
        self
    }

    /// Sets the value of [monitored_resource_types][crate::model::MetricDescriptor::monitored_resource_types].
    pub fn set_monitored_resource_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.monitored_resource_types = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for MetricDescriptor {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MetricDescriptor"
    }
}

/// Defines additional types related to [MetricDescriptor].
pub mod metric_descriptor {
    #[allow(unused_imports)]
    use super::*;

    /// Additional annotations that can be used to guide the usage of a metric.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct MetricDescriptorMetadata {

        /// Deprecated. Must use the
        /// [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage]
        /// instead.
        ///
        /// [google.api.MetricDescriptor.launch_stage]: crate::model::MetricDescriptor::launch_stage
        #[deprecated]
        pub launch_stage: crate::model::LaunchStage,

        /// The sampling period of metric data points. For metrics which are written
        /// periodically, consecutive data points are stored at this time interval,
        /// excluding data loss due to errors. Metrics with a higher granularity have
        /// a smaller sampling period.
        pub sample_period: std::option::Option<wkt::Duration>,

        /// The delay of data points caused by ingestion. Data points older than this
        /// age are guaranteed to be ingested and available to be read, excluding
        /// data loss due to errors.
        pub ingest_delay: std::option::Option<wkt::Duration>,

        /// The scope of the timeseries data of the metric.
        pub time_series_resource_hierarchy_level: std::vec::Vec<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl MetricDescriptorMetadata {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [launch_stage][crate::model::metric_descriptor::MetricDescriptorMetadata::launch_stage].
        #[deprecated]
        pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
            mut self,
            v: T,
        ) -> Self {
            self.launch_stage = v.into();
            self
        }

        /// Sets the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
        pub fn set_sample_period<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.sample_period = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [sample_period][crate::model::metric_descriptor::MetricDescriptorMetadata::sample_period].
        pub fn set_or_clear_sample_period<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.sample_period = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
        pub fn set_ingest_delay<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.ingest_delay = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [ingest_delay][crate::model::metric_descriptor::MetricDescriptorMetadata::ingest_delay].
        pub fn set_or_clear_ingest_delay<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.ingest_delay = v.map(|x| x.into());
            self
        }

        /// Sets the value of [time_series_resource_hierarchy_level][crate::model::metric_descriptor::MetricDescriptorMetadata::time_series_resource_hierarchy_level].
        pub fn set_time_series_resource_hierarchy_level<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::metric_descriptor::metric_descriptor_metadata::TimeSeriesResourceHierarchyLevel>
        {
            use std::iter::Iterator;
            self.time_series_resource_hierarchy_level = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for MetricDescriptorMetadata {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.MetricDescriptor.MetricDescriptorMetadata"
        }
    }

    /// Defines additional types related to [MetricDescriptorMetadata].
    pub mod metric_descriptor_metadata {
        #[allow(unused_imports)]
        use super::*;

        /// The resource hierarchy level of the timeseries data of a metric.
        ///
        /// # Working with unknown values
        ///
        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
        /// additional enum variants at any time. Adding new variants is not considered
        /// a breaking change. Applications should write their code in anticipation of:
        ///
        /// - New values appearing in future releases of the client library, **and**
        /// - New values received dynamically, without application changes.
        ///
        /// Please consult the [Working with enums] section in the user guide for some
        /// guidelines.
        ///
        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum TimeSeriesResourceHierarchyLevel {
            /// Do not use this default value.
            Unspecified,
            /// Scopes a metric to a project.
            Project,
            /// Scopes a metric to an organization.
            Organization,
            /// Scopes a metric to a folder.
            Folder,
            /// If set, the enum was initialized with an unknown value.
            ///
            /// Applications can examine the value using [TimeSeriesResourceHierarchyLevel::value] or
            /// [TimeSeriesResourceHierarchyLevel::name].
            UnknownValue(time_series_resource_hierarchy_level::UnknownValue),
        }

        #[doc(hidden)]
        pub mod time_series_resource_hierarchy_level {
            #[allow(unused_imports)]
            use super::*;
            #[derive(Clone, Debug, PartialEq)]
            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
        }

        impl TimeSeriesResourceHierarchyLevel {
            /// Gets the enum value.
            ///
            /// Returns `None` if the enum contains an unknown value deserialized from
            /// the string representation of enums.
            pub fn value(&self) -> std::option::Option<i32> {
                match self {
                    Self::Unspecified => std::option::Option::Some(0),
                    Self::Project => std::option::Option::Some(1),
                    Self::Organization => std::option::Option::Some(2),
                    Self::Folder => std::option::Option::Some(3),
                    Self::UnknownValue(u) => u.0.value(),
                }
            }

            /// Gets the enum value as a string.
            ///
            /// Returns `None` if the enum contains an unknown value deserialized from
            /// the integer representation of enums.
            pub fn name(&self) -> std::option::Option<&str> {
                match self {
                    Self::Unspecified => std::option::Option::Some(
                        "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED",
                    ),
                    Self::Project => std::option::Option::Some("PROJECT"),
                    Self::Organization => std::option::Option::Some("ORGANIZATION"),
                    Self::Folder => std::option::Option::Some("FOLDER"),
                    Self::UnknownValue(u) => u.0.name(),
                }
            }
        }

        impl std::default::Default for TimeSeriesResourceHierarchyLevel {
            fn default() -> Self {
                use std::convert::From;
                Self::from(0)
            }
        }

        impl std::fmt::Display for TimeSeriesResourceHierarchyLevel {
            fn fmt(
                &self,
                f: &mut std::fmt::Formatter<'_>,
            ) -> std::result::Result<(), std::fmt::Error> {
                wkt::internal::display_enum(f, self.name(), self.value())
            }
        }

        impl std::convert::From<i32> for TimeSeriesResourceHierarchyLevel {
            fn from(value: i32) -> Self {
                match value {
                    0 => Self::Unspecified,
                    1 => Self::Project,
                    2 => Self::Organization,
                    3 => Self::Folder,
                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
                        wkt::internal::UnknownEnumValue::Integer(value),
                    )),
                }
            }
        }

        impl std::convert::From<&str> for TimeSeriesResourceHierarchyLevel {
            fn from(value: &str) -> Self {
                use std::string::ToString;
                match value {
                    "TIME_SERIES_RESOURCE_HIERARCHY_LEVEL_UNSPECIFIED" => Self::Unspecified,
                    "PROJECT" => Self::Project,
                    "ORGANIZATION" => Self::Organization,
                    "FOLDER" => Self::Folder,
                    _ => Self::UnknownValue(time_series_resource_hierarchy_level::UnknownValue(
                        wkt::internal::UnknownEnumValue::String(value.to_string()),
                    )),
                }
            }
        }

        impl serde::ser::Serialize for TimeSeriesResourceHierarchyLevel {
            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
            where
                S: serde::Serializer,
            {
                match self {
                    Self::Unspecified => serializer.serialize_i32(0),
                    Self::Project => serializer.serialize_i32(1),
                    Self::Organization => serializer.serialize_i32(2),
                    Self::Folder => serializer.serialize_i32(3),
                    Self::UnknownValue(u) => u.0.serialize(serializer),
                }
            }
        }

        impl<'de> serde::de::Deserialize<'de> for TimeSeriesResourceHierarchyLevel {
            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
            where
                D: serde::Deserializer<'de>,
            {
                deserializer.deserialize_any(wkt::internal::EnumVisitor::<TimeSeriesResourceHierarchyLevel>::new(
                    ".google.api.MetricDescriptor.MetricDescriptorMetadata.TimeSeriesResourceHierarchyLevel"))
            }
        }
    }

    /// The kind of measurement. It describes how the data is reported.
    /// For information on setting the start time and end time based on
    /// the MetricKind, see [TimeInterval][google.monitoring.v3.TimeInterval].
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum MetricKind {
        /// Do not use this default value.
        Unspecified,
        /// An instantaneous measurement of a value.
        Gauge,
        /// The change in a value during a time interval.
        Delta,
        /// A value accumulated over a time interval.  Cumulative
        /// measurements in a time series should have the same start time
        /// and increasing end times, until an event resets the cumulative
        /// value to zero and sets a new start time for the following
        /// points.
        Cumulative,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [MetricKind::value] or
        /// [MetricKind::name].
        UnknownValue(metric_kind::UnknownValue),
    }

    #[doc(hidden)]
    pub mod metric_kind {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl MetricKind {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Gauge => std::option::Option::Some(1),
                Self::Delta => std::option::Option::Some(2),
                Self::Cumulative => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("METRIC_KIND_UNSPECIFIED"),
                Self::Gauge => std::option::Option::Some("GAUGE"),
                Self::Delta => std::option::Option::Some("DELTA"),
                Self::Cumulative => std::option::Option::Some("CUMULATIVE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for MetricKind {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for MetricKind {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for MetricKind {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Gauge,
                2 => Self::Delta,
                3 => Self::Cumulative,
                _ => Self::UnknownValue(metric_kind::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for MetricKind {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "METRIC_KIND_UNSPECIFIED" => Self::Unspecified,
                "GAUGE" => Self::Gauge,
                "DELTA" => Self::Delta,
                "CUMULATIVE" => Self::Cumulative,
                _ => Self::UnknownValue(metric_kind::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for MetricKind {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Gauge => serializer.serialize_i32(1),
                Self::Delta => serializer.serialize_i32(2),
                Self::Cumulative => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for MetricKind {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MetricKind>::new(
                ".google.api.MetricDescriptor.MetricKind",
            ))
        }
    }

    /// The value type of a metric.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ValueType {
        /// Do not use this default value.
        Unspecified,
        /// The value is a boolean.
        /// This value type can be used only if the metric kind is `GAUGE`.
        Bool,
        /// The value is a signed 64-bit integer.
        Int64,
        /// The value is a double precision floating point number.
        Double,
        /// The value is a text string.
        /// This value type can be used only if the metric kind is `GAUGE`.
        String,
        /// The value is a [`Distribution`][google.api.Distribution].
        ///
        /// [google.api.Distribution]: crate::model::Distribution
        Distribution,
        /// The value is money.
        Money,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [ValueType::value] or
        /// [ValueType::name].
        UnknownValue(value_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod value_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl ValueType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Bool => std::option::Option::Some(1),
                Self::Int64 => std::option::Option::Some(2),
                Self::Double => std::option::Option::Some(3),
                Self::String => std::option::Option::Some(4),
                Self::Distribution => std::option::Option::Some(5),
                Self::Money => std::option::Option::Some(6),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("VALUE_TYPE_UNSPECIFIED"),
                Self::Bool => std::option::Option::Some("BOOL"),
                Self::Int64 => std::option::Option::Some("INT64"),
                Self::Double => std::option::Option::Some("DOUBLE"),
                Self::String => std::option::Option::Some("STRING"),
                Self::Distribution => std::option::Option::Some("DISTRIBUTION"),
                Self::Money => std::option::Option::Some("MONEY"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for ValueType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for ValueType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for ValueType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Bool,
                2 => Self::Int64,
                3 => Self::Double,
                4 => Self::String,
                5 => Self::Distribution,
                6 => Self::Money,
                _ => Self::UnknownValue(value_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for ValueType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "VALUE_TYPE_UNSPECIFIED" => Self::Unspecified,
                "BOOL" => Self::Bool,
                "INT64" => Self::Int64,
                "DOUBLE" => Self::Double,
                "STRING" => Self::String,
                "DISTRIBUTION" => Self::Distribution,
                "MONEY" => Self::Money,
                _ => Self::UnknownValue(value_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for ValueType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Bool => serializer.serialize_i32(1),
                Self::Int64 => serializer.serialize_i32(2),
                Self::Double => serializer.serialize_i32(3),
                Self::String => serializer.serialize_i32(4),
                Self::Distribution => serializer.serialize_i32(5),
                Self::Money => serializer.serialize_i32(6),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for ValueType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueType>::new(
                ".google.api.MetricDescriptor.ValueType",
            ))
        }
    }
}

/// A specific metric, identified by specifying values for all of the
/// labels of a [`MetricDescriptor`][google.api.MetricDescriptor].
///
/// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Metric {
    /// An existing metric type, see
    /// [google.api.MetricDescriptor][google.api.MetricDescriptor]. For example,
    /// `custom.googleapis.com/invoice/paid/amount`.
    ///
    /// [google.api.MetricDescriptor]: crate::model::MetricDescriptor
    pub r#type: std::string::String,

    /// The set of label values that uniquely identify this metric. All
    /// labels listed in the `MetricDescriptor` must be assigned values.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Metric {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [r#type][crate::model::Metric::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::Metric::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for Metric {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Metric"
    }
}

/// An object that describes the schema of a
/// [MonitoredResource][google.api.MonitoredResource] object using a type name
/// and a set of labels.  For example, the monitored resource descriptor for
/// Google Compute Engine VM instances has a type of
/// `"gce_instance"` and specifies the use of the labels `"instance_id"` and
/// `"zone"` to identify particular VM instances.
///
/// Different APIs can support different monitored resource types. APIs generally
/// provide a `list` method that returns the monitored resource descriptors used
/// by the API.
///
/// [google.api.MonitoredResource]: crate::model::MonitoredResource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MonitoredResourceDescriptor {
    /// Optional. The resource name of the monitored resource descriptor:
    /// `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where
    /// {type} is the value of the `type` field in this object and
    /// {project_id} is a project ID that provides API-specific context for
    /// accessing the type.  APIs that do not use project information can use the
    /// resource name format `"monitoredResourceDescriptors/{type}"`.
    pub name: std::string::String,

    /// Required. The monitored resource type. For example, the type
    /// `"cloudsql_database"` represents databases in Google Cloud SQL.
    /// For a list of types, see [Monitored resource
    /// types](https://cloud.google.com/monitoring/api/resources)
    /// and [Logging resource
    /// types](https://cloud.google.com/logging/docs/api/v2/resource-list).
    pub r#type: std::string::String,

    /// Optional. A concise name for the monitored resource type that might be
    /// displayed in user interfaces. It should be a Title Cased Noun Phrase,
    /// without any article or other determiners. For example,
    /// `"Google Cloud SQL Database"`.
    pub display_name: std::string::String,

    /// Optional. A detailed description of the monitored resource type that might
    /// be used in documentation.
    pub description: std::string::String,

    /// Required. A set of labels used to describe instances of this monitored
    /// resource type. For example, an individual Google Cloud SQL database is
    /// identified by values for the labels `"database_id"` and `"zone"`.
    pub labels: std::vec::Vec<crate::model::LabelDescriptor>,

    /// Optional. The launch stage of the monitored resource definition.
    pub launch_stage: crate::model::LaunchStage,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MonitoredResourceDescriptor {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::MonitoredResourceDescriptor::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::MonitoredResourceDescriptor::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::MonitoredResourceDescriptor::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::MonitoredResourceDescriptor::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::MonitoredResourceDescriptor::labels].
    pub fn set_labels<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::LabelDescriptor>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [launch_stage][crate::model::MonitoredResourceDescriptor::launch_stage].
    pub fn set_launch_stage<T: std::convert::Into<crate::model::LaunchStage>>(
        mut self,
        v: T,
    ) -> Self {
        self.launch_stage = v.into();
        self
    }
}

impl wkt::message::Message for MonitoredResourceDescriptor {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MonitoredResourceDescriptor"
    }
}

/// An object representing a resource that can be used for monitoring, logging,
/// billing, or other purposes. Examples include virtual machine instances,
/// databases, and storage devices such as disks. The `type` field identifies a
/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object
/// that describes the resource's schema. Information in the `labels` field
/// identifies the actual resource and its attributes according to the schema.
/// For example, a particular Compute Engine VM instance could be represented by
/// the following object, because the
/// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for
/// `"gce_instance"` has labels
/// `"project_id"`, `"instance_id"` and `"zone"`:
///
/// ```norust
/// { "type": "gce_instance",
///   "labels": { "project_id": "my-project",
///               "instance_id": "12345678901234",
///               "zone": "us-central1-a" }}
/// ```
///
/// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MonitoredResource {
    /// Required. The monitored resource type. This field must match
    /// the `type` field of a
    /// [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor]
    /// object. For example, the type of a Compute Engine VM instance is
    /// `gce_instance`. Some descriptors include the service name in the type; for
    /// example, the type of a Datastream stream is
    /// `datastream.googleapis.com/Stream`.
    ///
    /// [google.api.MonitoredResourceDescriptor]: crate::model::MonitoredResourceDescriptor
    pub r#type: std::string::String,

    /// Required. Values for all of the labels listed in the associated monitored
    /// resource descriptor. For example, Compute Engine VM instances use the
    /// labels `"project_id"`, `"instance_id"`, and `"zone"`.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MonitoredResource {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [r#type][crate::model::MonitoredResource::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [labels][crate::model::MonitoredResource::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for MonitoredResource {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MonitoredResource"
    }
}

/// Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource]
/// object. [MonitoredResource][google.api.MonitoredResource] objects contain the
/// minimum set of information to uniquely identify a monitored resource
/// instance. There is some other useful auxiliary metadata. Monitoring and
/// Logging use an ingestion pipeline to extract metadata for cloud resources of
/// all types, and store the metadata in this message.
///
/// [google.api.MonitoredResource]: crate::model::MonitoredResource
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MonitoredResourceMetadata {
    /// Output only. Values for predefined system metadata labels.
    /// System labels are a kind of metadata extracted by Google, including
    /// "machine_image", "vpc", "subnet_id",
    /// "security_group", "name", etc.
    /// System label values can be only strings, Boolean values, or a list of
    /// strings. For example:
    ///
    /// ```norust
    /// { "name": "my-test-instance",
    ///   "security_group": ["a", "b", "c"],
    ///   "spot_instance": false }
    /// ```
    pub system_labels: std::option::Option<wkt::Struct>,

    /// Output only. A map of user-defined metadata labels.
    pub user_labels: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MonitoredResourceMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
    pub fn set_system_labels<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.system_labels = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [system_labels][crate::model::MonitoredResourceMetadata::system_labels].
    pub fn set_or_clear_system_labels<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Struct>,
    {
        self.system_labels = v.map(|x| x.into());
        self
    }

    /// Sets the value of [user_labels][crate::model::MonitoredResourceMetadata::user_labels].
    pub fn set_user_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.user_labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for MonitoredResourceMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MonitoredResourceMetadata"
    }
}

/// Monitoring configuration of the service.
///
/// The example below shows how to configure monitored resources and metrics
/// for monitoring. In the example, a monitored resource and two metrics are
/// defined. The `library.googleapis.com/book/returned_count` metric is sent
/// to both producer and consumer projects, whereas the
/// `library.googleapis.com/book/num_overdue` metric is only sent to the
/// consumer project.
///
/// ```norust
/// monitored_resources:
/// - type: library.googleapis.com/Branch
///   display_name: "Library Branch"
///   description: "A branch of a library."
///   launch_stage: GA
///   labels:
///   - key: resource_container
///     description: "The Cloud container (ie. project id) for the Branch."
///   - key: location
///     description: "The location of the library branch."
///   - key: branch_id
///     description: "The id of the branch."
/// metrics:
/// - name: library.googleapis.com/book/returned_count
///   display_name: "Books Returned"
///   description: "The count of books that have been returned."
///   launch_stage: GA
///   metric_kind: DELTA
///   value_type: INT64
///   unit: "1"
///   labels:
///   - key: customer_id
///     description: "The id of the customer."
/// - name: library.googleapis.com/book/num_overdue
///   display_name: "Books Overdue"
///   description: "The current number of overdue books."
///   launch_stage: GA
///   metric_kind: GAUGE
///   value_type: INT64
///   unit: "1"
///   labels:
///   - key: customer_id
///     description: "The id of the customer."
/// monitoring:
///   producer_destinations:
///   - monitored_resource: library.googleapis.com/Branch
///     metrics:
///     - library.googleapis.com/book/returned_count
///   consumer_destinations:
///   - monitored_resource: library.googleapis.com/Branch
///     metrics:
///     - library.googleapis.com/book/returned_count
///     - library.googleapis.com/book/num_overdue
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Monitoring {
    /// Monitoring configurations for sending metrics to the producer project.
    /// There can be multiple producer destinations. A monitored resource type may
    /// appear in multiple monitoring destinations if different aggregations are
    /// needed for different sets of metrics associated with that monitored
    /// resource type. A monitored resource and metric pair may only be used once
    /// in the Monitoring configuration.
    pub producer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,

    /// Monitoring configurations for sending metrics to the consumer project.
    /// There can be multiple consumer destinations. A monitored resource type may
    /// appear in multiple monitoring destinations if different aggregations are
    /// needed for different sets of metrics associated with that monitored
    /// resource type. A monitored resource and metric pair may only be used once
    /// in the Monitoring configuration.
    pub consumer_destinations: std::vec::Vec<crate::model::monitoring::MonitoringDestination>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Monitoring {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [producer_destinations][crate::model::Monitoring::producer_destinations].
    pub fn set_producer_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
    {
        use std::iter::Iterator;
        self.producer_destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [consumer_destinations][crate::model::Monitoring::consumer_destinations].
    pub fn set_consumer_destinations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::monitoring::MonitoringDestination>,
    {
        use std::iter::Iterator;
        self.consumer_destinations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Monitoring {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Monitoring"
    }
}

/// Defines additional types related to [Monitoring].
pub mod monitoring {
    #[allow(unused_imports)]
    use super::*;

    /// Configuration of a specific monitoring destination (the producer project
    /// or the consumer project).
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct MonitoringDestination {
        /// The monitored resource type. The type must be defined in
        /// [Service.monitored_resources][google.api.Service.monitored_resources]
        /// section.
        ///
        /// [google.api.Service.monitored_resources]: crate::model::Service::monitored_resources
        pub monitored_resource: std::string::String,

        /// Types of the metrics to report to this monitoring destination.
        /// Each type must be defined in
        /// [Service.metrics][google.api.Service.metrics] section.
        ///
        /// [google.api.Service.metrics]: crate::model::Service::metrics
        pub metrics: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl MonitoringDestination {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [monitored_resource][crate::model::monitoring::MonitoringDestination::monitored_resource].
        pub fn set_monitored_resource<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.monitored_resource = v.into();
            self
        }

        /// Sets the value of [metrics][crate::model::monitoring::MonitoringDestination::metrics].
        pub fn set_metrics<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.metrics = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for MonitoringDestination {
        fn typename() -> &'static str {
            "type.googleapis.com/google.api.Monitoring.MonitoringDestination"
        }
    }
}

/// Google API Policy Annotation
///
/// This message defines a simple API policy annotation that can be used to
/// annotate API request and response message fields with applicable policies.
/// One field may have multiple applicable policies that must all be satisfied
/// before a request can be processed. This policy annotation is used to
/// generate the overall policy that will be used for automatic runtime
/// policy enforcement and documentation generation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct FieldPolicy {
    /// Selects one or more request or response message fields to apply this
    /// `FieldPolicy`.
    ///
    /// When a `FieldPolicy` is used in proto annotation, the selector must
    /// be left as empty. The service config generator will automatically fill
    /// the correct value.
    ///
    /// When a `FieldPolicy` is used in service config, the selector must be a
    /// comma-separated string with valid request or response field paths,
    /// such as "foo.bar" or "foo.bar,foo.baz".
    pub selector: std::string::String,

    /// Specifies the required permission(s) for the resource referred to by the
    /// field. It requires the field contains a valid resource reference, and
    /// the request must pass the permission checks to proceed. For example,
    /// "resourcemanager.projects.get".
    pub resource_permission: std::string::String,

    /// Specifies the resource type for the resource referred to by the field.
    pub resource_type: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl FieldPolicy {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::FieldPolicy::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [resource_permission][crate::model::FieldPolicy::resource_permission].
    pub fn set_resource_permission<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.resource_permission = v.into();
        self
    }

    /// Sets the value of [resource_type][crate::model::FieldPolicy::resource_type].
    pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.resource_type = v.into();
        self
    }
}

impl wkt::message::Message for FieldPolicy {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.FieldPolicy"
    }
}

/// Defines policies applying to an RPC method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MethodPolicy {
    /// Selects a method to which these policies should be enforced, for example,
    /// "google.pubsub.v1.Subscriber.CreateSubscription".
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// NOTE: This field must not be set in the proto annotation. It will be
    /// automatically filled by the service config compiler .
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// Policies that are applicable to the request message.
    pub request_policies: std::vec::Vec<crate::model::FieldPolicy>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MethodPolicy {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::MethodPolicy::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [request_policies][crate::model::MethodPolicy::request_policies].
    pub fn set_request_policies<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::FieldPolicy>,
    {
        use std::iter::Iterator;
        self.request_policies = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for MethodPolicy {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MethodPolicy"
    }
}

/// Quota configuration helps to achieve fairness and budgeting in service
/// usage.
///
/// The metric based quota configuration works this way:
///
/// - The service configuration defines a set of metrics.
/// - For API calls, the quota.metric_rules maps methods to metrics with
///   corresponding costs.
/// - The quota.limits defines limits on the metrics, which will be used for
///   quota checks at runtime.
///
/// An example quota configuration in yaml format:
///
/// quota:
/// limits:
///
/// ```norust
///  - name: apiWriteQpsPerProject
///    metric: library.googleapis.com/write_calls
///    unit: "1/min/{project}"  # rate limit for consumer projects
///    values:
///      STANDARD: 10000
///
///
///  (The metric rules bind all methods to the read_calls metric,
///   except for the UpdateBook and DeleteBook methods. These two methods
///   are mapped to the write_calls metric, with the UpdateBook method
///   consuming at twice rate as the DeleteBook method.)
///  metric_rules:
///  - selector: "*"
///    metric_costs:
///      library.googleapis.com/read_calls: 1
///  - selector: google.example.library.v1.LibraryService.UpdateBook
///    metric_costs:
///      library.googleapis.com/write_calls: 2
///  - selector: google.example.library.v1.LibraryService.DeleteBook
///    metric_costs:
///      library.googleapis.com/write_calls: 1
/// ```
///
/// Corresponding Metric definition:
///
/// ```norust
///  metrics:
///  - name: library.googleapis.com/read_calls
///    display_name: Read requests
///    metric_kind: DELTA
///    value_type: INT64
///
///  - name: library.googleapis.com/write_calls
///    display_name: Write requests
///    metric_kind: DELTA
///    value_type: INT64
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Quota {
    /// List of QuotaLimit definitions for the service.
    pub limits: std::vec::Vec<crate::model::QuotaLimit>,

    /// List of MetricRule definitions, each one mapping a selected method to one
    /// or more metrics.
    pub metric_rules: std::vec::Vec<crate::model::MetricRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Quota {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [limits][crate::model::Quota::limits].
    pub fn set_limits<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::QuotaLimit>,
    {
        use std::iter::Iterator;
        self.limits = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [metric_rules][crate::model::Quota::metric_rules].
    pub fn set_metric_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MetricRule>,
    {
        use std::iter::Iterator;
        self.metric_rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Quota {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Quota"
    }
}

/// Bind API methods to metrics. Binding a method to a metric causes that
/// metric's configured quota behaviors to apply to the method call.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MetricRule {
    /// Selects the methods to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// Metrics to update when the selected methods are called, and the associated
    /// cost applied to each metric.
    ///
    /// The key of the map is the metric name, and the values are the amount
    /// increased for the metric against which the quota limits are defined.
    /// The value must not be negative.
    pub metric_costs: std::collections::HashMap<std::string::String, i64>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MetricRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::MetricRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [metric_costs][crate::model::MetricRule::metric_costs].
    pub fn set_metric_costs<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<i64>,
    {
        use std::iter::Iterator;
        self.metric_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for MetricRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.MetricRule"
    }
}

/// `QuotaLimit` defines a specific limit that applies over a specified duration
/// for a limit type. There can be at most one limit for a duration and limit
/// type combination defined within a `QuotaGroup`.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct QuotaLimit {
    /// Name of the quota limit.
    ///
    /// The name must be provided, and it must be unique within the service. The
    /// name can only include alphanumeric characters as well as '-'.
    ///
    /// The maximum length of the limit name is 64 characters.
    pub name: std::string::String,

    /// Optional. User-visible, extended description for this quota limit.
    /// Should be used only when more context is needed to understand this limit
    /// than provided by the limit's display name (see: `display_name`).
    pub description: std::string::String,

    /// Default number of tokens that can be consumed during the specified
    /// duration. This is the number of tokens assigned when a client
    /// application developer activates the service for his/her project.
    ///
    /// Specifying a value of 0 will block all requests. This can be used if you
    /// are provisioning quota to selected consumers and blocking others.
    /// Similarly, a value of -1 will indicate an unlimited quota. No other
    /// negative values are allowed.
    ///
    /// Used by group-based quotas only.
    pub default_limit: i64,

    /// Maximum number of tokens that can be consumed during the specified
    /// duration. Client application developers can override the default limit up
    /// to this maximum. If specified, this value cannot be set to a value less
    /// than the default limit. If not specified, it is set to the default limit.
    ///
    /// To allow clients to apply overrides with no upper bound, set this to -1,
    /// indicating unlimited maximum quota.
    ///
    /// Used by group-based quotas only.
    pub max_limit: i64,

    /// Free tier value displayed in the Developers Console for this limit.
    /// The free tier is the number of tokens that will be subtracted from the
    /// billed amount when billing is enabled.
    /// This field can only be set on a limit with duration "1d", in a billable
    /// group; it is invalid on any other limit. If this field is not set, it
    /// defaults to 0, indicating that there is no free tier for this service.
    ///
    /// Used by group-based quotas only.
    pub free_tier: i64,

    /// Duration of this limit in textual notation. Must be "100s" or "1d".
    ///
    /// Used by group-based quotas only.
    pub duration: std::string::String,

    /// The name of the metric this quota limit applies to. The quota limits with
    /// the same metric will be checked together during runtime. The metric must be
    /// defined within the service config.
    pub metric: std::string::String,

    /// Specify the unit of the quota limit. It uses the same syntax as
    /// [MetricDescriptor.unit][google.api.MetricDescriptor.unit]. The supported
    /// unit kinds are determined by the quota backend system.
    ///
    /// Here are some examples:
    ///
    /// * "1/min/{project}" for quota per minute per project.
    ///
    /// Note: the order of unit components is insignificant.
    /// The "1" at the beginning is required to follow the metric unit syntax.
    ///
    /// [google.api.MetricDescriptor.unit]: crate::model::MetricDescriptor::unit
    pub unit: std::string::String,

    /// Tiered limit values. You must specify this as a key:value pair, with an
    /// integer value that is the maximum number of requests allowed for the
    /// specified unit. Currently only STANDARD is supported.
    pub values: std::collections::HashMap<std::string::String, i64>,

    /// User-visible display name for this limit.
    /// Optional. If not set, the UI will provide a default display name based on
    /// the quota configuration. This field can be used to override the default
    /// display name generated from the configuration.
    pub display_name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl QuotaLimit {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::QuotaLimit::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::QuotaLimit::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [default_limit][crate::model::QuotaLimit::default_limit].
    pub fn set_default_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.default_limit = v.into();
        self
    }

    /// Sets the value of [max_limit][crate::model::QuotaLimit::max_limit].
    pub fn set_max_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.max_limit = v.into();
        self
    }

    /// Sets the value of [free_tier][crate::model::QuotaLimit::free_tier].
    pub fn set_free_tier<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.free_tier = v.into();
        self
    }

    /// Sets the value of [duration][crate::model::QuotaLimit::duration].
    pub fn set_duration<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.duration = v.into();
        self
    }

    /// Sets the value of [metric][crate::model::QuotaLimit::metric].
    pub fn set_metric<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.metric = v.into();
        self
    }

    /// Sets the value of [unit][crate::model::QuotaLimit::unit].
    pub fn set_unit<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.unit = v.into();
        self
    }

    /// Sets the value of [values][crate::model::QuotaLimit::values].
    pub fn set_values<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<i64>,
    {
        use std::iter::Iterator;
        self.values = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [display_name][crate::model::QuotaLimit::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }
}

impl wkt::message::Message for QuotaLimit {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.QuotaLimit"
    }
}

/// A simple descriptor of a resource type.
///
/// ResourceDescriptor annotates a resource message (either by means of a
/// protobuf annotation or use in the service config), and associates the
/// resource's schema, the resource type, and the pattern of the resource name.
///
/// Example:
///
/// ```norust
/// message Topic {
///   // Indicates this message defines a resource schema.
///   // Declares the resource type in the format of {service}/{kind}.
///   // For Kubernetes resources, the format is {api group}/{kind}.
///   option (google.api.resource) = {
///     type: "pubsub.googleapis.com/Topic"
///     pattern: "projects/{project}/topics/{topic}"
///   };
/// }
/// ```
///
/// The ResourceDescriptor Yaml config will look like:
///
/// ```norust
/// resources:
/// - type: "pubsub.googleapis.com/Topic"
///   pattern: "projects/{project}/topics/{topic}"
/// ```
///
/// Sometimes, resources have multiple patterns, typically because they can
/// live under multiple parents.
///
/// Example:
///
/// ```norust
/// message LogEntry {
///   option (google.api.resource) = {
///     type: "logging.googleapis.com/LogEntry"
///     pattern: "projects/{project}/logs/{log}"
///     pattern: "folders/{folder}/logs/{log}"
///     pattern: "organizations/{organization}/logs/{log}"
///     pattern: "billingAccounts/{billing_account}/logs/{log}"
///   };
/// }
/// ```
///
/// The ResourceDescriptor Yaml config will look like:
///
/// ```norust
/// resources:
/// - type: 'logging.googleapis.com/LogEntry'
///   pattern: "projects/{project}/logs/{log}"
///   pattern: "folders/{folder}/logs/{log}"
///   pattern: "organizations/{organization}/logs/{log}"
///   pattern: "billingAccounts/{billing_account}/logs/{log}"
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceDescriptor {
    /// The resource type. It must be in the format of
    /// {service_name}/{resource_type_kind}. The `resource_type_kind` must be
    /// singular and must not include version numbers.
    ///
    /// Example: `storage.googleapis.com/Bucket`
    ///
    /// The value of the resource_type_kind must follow the regular expression
    /// /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
    /// should use PascalCase (UpperCamelCase). The maximum number of
    /// characters allowed for the `resource_type_kind` is 100.
    pub r#type: std::string::String,

    /// Optional. The relative resource name pattern associated with this resource
    /// type. The DNS prefix of the full resource name shouldn't be specified here.
    ///
    /// The path pattern must follow the syntax, which aligns with HTTP binding
    /// syntax:
    ///
    /// ```norust
    /// Template = Segment { "/" Segment } ;
    /// Segment = LITERAL | Variable ;
    /// Variable = "{" LITERAL "}" ;
    /// ```
    ///
    /// Examples:
    ///
    /// ```norust
    /// - "projects/{project}/topics/{topic}"
    /// - "projects/{project}/knowledgeBases/{knowledge_base}"
    /// ```
    ///
    /// The components in braces correspond to the IDs for each resource in the
    /// hierarchy. It is expected that, if multiple patterns are provided,
    /// the same component name (e.g. "project") refers to IDs of the same
    /// type of resource.
    pub pattern: std::vec::Vec<std::string::String>,

    /// Optional. The field on the resource that designates the resource name
    /// field. If omitted, this is assumed to be "name".
    pub name_field: std::string::String,

    /// Optional. The historical or future-looking state of the resource pattern.
    ///
    /// Example:
    ///
    /// ```norust
    /// // The InspectTemplate message originally only supported resource
    /// // names with organization, and project was added later.
    /// message InspectTemplate {
    ///   option (google.api.resource) = {
    ///     type: "dlp.googleapis.com/InspectTemplate"
    ///     pattern:
    ///     "organizations/{organization}/inspectTemplates/{inspect_template}"
    ///     pattern: "projects/{project}/inspectTemplates/{inspect_template}"
    ///     history: ORIGINALLY_SINGLE_PATTERN
    ///   };
    /// }
    /// ```
    pub history: crate::model::resource_descriptor::History,

    /// The plural name used in the resource name and permission names, such as
    /// 'projects' for the resource name of 'projects/{project}' and the permission
    /// name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception
    /// to this is for Nested Collections that have stuttering names, as defined
    /// in [AIP-122](https://google.aip.dev/122#nested-collections), where the
    /// collection ID in the resource name pattern does not necessarily directly
    /// match the `plural` value.
    ///
    /// It is the same concept of the `plural` field in k8s CRD spec
    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
    ///
    /// Note: The plural form is required even for singleton resources. See
    /// <https://aip.dev/156>
    pub plural: std::string::String,

    /// The same concept of the `singular` field in k8s CRD spec
    /// <https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/>
    /// Such as "project" for the `resourcemanager.googleapis.com/Project` type.
    pub singular: std::string::String,

    /// Style flag(s) for this resource.
    /// These indicate that a resource is expected to conform to a given
    /// style. See the specific style flags for additional information.
    pub style: std::vec::Vec<crate::model::resource_descriptor::Style>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceDescriptor {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [r#type][crate::model::ResourceDescriptor::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [pattern][crate::model::ResourceDescriptor::pattern].
    pub fn set_pattern<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.pattern = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [name_field][crate::model::ResourceDescriptor::name_field].
    pub fn set_name_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name_field = v.into();
        self
    }

    /// Sets the value of [history][crate::model::ResourceDescriptor::history].
    pub fn set_history<T: std::convert::Into<crate::model::resource_descriptor::History>>(
        mut self,
        v: T,
    ) -> Self {
        self.history = v.into();
        self
    }

    /// Sets the value of [plural][crate::model::ResourceDescriptor::plural].
    pub fn set_plural<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.plural = v.into();
        self
    }

    /// Sets the value of [singular][crate::model::ResourceDescriptor::singular].
    pub fn set_singular<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.singular = v.into();
        self
    }

    /// Sets the value of [style][crate::model::ResourceDescriptor::style].
    pub fn set_style<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::resource_descriptor::Style>,
    {
        use std::iter::Iterator;
        self.style = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ResourceDescriptor {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ResourceDescriptor"
    }
}

/// Defines additional types related to [ResourceDescriptor].
pub mod resource_descriptor {
    #[allow(unused_imports)]
    use super::*;

    /// A description of the historical or future-looking state of the
    /// resource pattern.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum History {
        /// The "unset" value.
        Unspecified,
        /// The resource originally had one pattern and launched as such, and
        /// additional patterns were added later.
        OriginallySinglePattern,
        /// The resource has one pattern, but the API owner expects to add more
        /// later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents
        /// that from being necessary once there are multiple patterns.)
        FutureMultiPattern,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [History::value] or
        /// [History::name].
        UnknownValue(history::UnknownValue),
    }

    #[doc(hidden)]
    pub mod history {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl History {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::OriginallySinglePattern => std::option::Option::Some(1),
                Self::FutureMultiPattern => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("HISTORY_UNSPECIFIED"),
                Self::OriginallySinglePattern => {
                    std::option::Option::Some("ORIGINALLY_SINGLE_PATTERN")
                }
                Self::FutureMultiPattern => std::option::Option::Some("FUTURE_MULTI_PATTERN"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for History {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for History {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for History {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::OriginallySinglePattern,
                2 => Self::FutureMultiPattern,
                _ => Self::UnknownValue(history::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for History {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "HISTORY_UNSPECIFIED" => Self::Unspecified,
                "ORIGINALLY_SINGLE_PATTERN" => Self::OriginallySinglePattern,
                "FUTURE_MULTI_PATTERN" => Self::FutureMultiPattern,
                _ => Self::UnknownValue(history::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for History {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::OriginallySinglePattern => serializer.serialize_i32(1),
                Self::FutureMultiPattern => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for History {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<History>::new(
                ".google.api.ResourceDescriptor.History",
            ))
        }
    }

    /// A flag representing a specific style that a resource claims to conform to.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Style {
        /// The unspecified value. Do not use.
        Unspecified,
        /// This resource is intended to be "declarative-friendly".
        ///
        /// Declarative-friendly resources must be more strictly consistent, and
        /// setting this to true communicates to tools that this resource should
        /// adhere to declarative-friendly expectations.
        ///
        /// Note: This is used by the API linter (linter.aip.dev) to enable
        /// additional checks.
        DeclarativeFriendly,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Style::value] or
        /// [Style::name].
        UnknownValue(style::UnknownValue),
    }

    #[doc(hidden)]
    pub mod style {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Style {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::DeclarativeFriendly => std::option::Option::Some(1),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STYLE_UNSPECIFIED"),
                Self::DeclarativeFriendly => std::option::Option::Some("DECLARATIVE_FRIENDLY"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Style {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Style {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Style {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::DeclarativeFriendly,
                _ => Self::UnknownValue(style::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Style {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STYLE_UNSPECIFIED" => Self::Unspecified,
                "DECLARATIVE_FRIENDLY" => Self::DeclarativeFriendly,
                _ => Self::UnknownValue(style::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Style {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::DeclarativeFriendly => serializer.serialize_i32(1),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Style {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Style>::new(
                ".google.api.ResourceDescriptor.Style",
            ))
        }
    }
}

/// Defines a proto annotation that describes a string field that refers to
/// an API resource.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceReference {
    /// The resource type that the annotated field references.
    ///
    /// Example:
    ///
    /// ```norust
    /// message Subscription {
    ///   string topic = 2 [(google.api.resource_reference) = {
    ///     type: "pubsub.googleapis.com/Topic"
    ///   }];
    /// }
    /// ```
    ///
    /// Occasionally, a field may reference an arbitrary resource. In this case,
    /// APIs use the special value * in their resource reference.
    ///
    /// Example:
    ///
    /// ```norust
    /// message GetIamPolicyRequest {
    ///   string resource = 2 [(google.api.resource_reference) = {
    ///     type: "*"
    ///   }];
    /// }
    /// ```
    pub r#type: std::string::String,

    /// The resource type of a child collection that the annotated field
    /// references. This is useful for annotating the `parent` field that
    /// doesn't have a fixed resource type.
    ///
    /// Example:
    ///
    /// ```norust
    /// message ListLogEntriesRequest {
    ///   string parent = 1 [(google.api.resource_reference) = {
    ///     child_type: "logging.googleapis.com/LogEntry"
    ///   };
    /// }
    /// ```
    pub child_type: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceReference {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [r#type][crate::model::ResourceReference::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [child_type][crate::model::ResourceReference::child_type].
    pub fn set_child_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.child_type = v.into();
        self
    }
}

impl wkt::message::Message for ResourceReference {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.ResourceReference"
    }
}

/// Specifies the routing information that should be sent along with the request
/// in the form of routing header.
/// **NOTE:** All service configuration rules follow the "last one wins" order.
///
/// The examples below will apply to an RPC which has the following request type:
///
/// Message Definition:
///
/// ```norust
/// message Request {
///   // The name of the Table
///   // Values can be of the following formats:
///   // - `projects/<project>/tables/<table>`
///   // - `projects/<project>/instances/<instance>/tables/<table>`
///   // - `region/<region>/zones/<zone>/tables/<table>`
///   string table_name = 1;
///
///   // This value specifies routing for replication.
///   // It can be in the following formats:
///   // - `profiles/<profile_id>`
///   // - a legacy `profile_id` that can be any string
///   string app_profile_id = 2;
/// }
/// ```
///
/// Example message:
///
/// ```norust
/// {
///   table_name: projects/proj_foo/instances/instance_bar/table/table_baz,
///   app_profile_id: profiles/prof_qux
/// }
/// ```
///
/// The routing header consists of one or multiple key-value pairs. Every key
/// and value must be percent-encoded, and joined together in the format of
/// `key1=value1&key2=value2`.
/// The examples below skip the percent-encoding for readability.
///
/// Example 1
///
/// Extracting a field from the request to put into the routing header
/// unchanged, with the key equal to the field name.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take the `app_profile_id`.
///   routing_parameters {
///     field: "app_profile_id"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params: app_profile_id=profiles/prof_qux
/// ```
///
/// Example 2
///
/// Extracting a field from the request to put into the routing header
/// unchanged, with the key different from the field name.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take the `app_profile_id`, but name it `routing_id` in the header.
///   routing_parameters {
///     field: "app_profile_id"
///     path_template: "{routing_id=**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params: routing_id=profiles/prof_qux
/// ```
///
/// Example 3
///
/// Extracting a field from the request to put into the routing
/// header, while matching a path template syntax on the field's value.
///
/// NB: it is more useful to send nothing than to send garbage for the purpose
/// of dynamic routing, since garbage pollutes cache. Thus the matching.
///
/// Sub-example 3a
///
/// The field matches the template.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take the `table_name`, if it's well-formed (with project-based
///   // syntax).
///   routing_parameters {
///     field: "table_name"
///     path_template: "{table_name=projects/*/instances/*/**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
/// ```
///
/// Sub-example 3b
///
/// The field does not match the template.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take the `table_name`, if it's well-formed (with region-based
///   // syntax).
///   routing_parameters {
///     field: "table_name"
///     path_template: "{table_name=regions/*/zones/*/**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// <no routing header will be sent>
/// ```
///
/// Sub-example 3c
///
/// Multiple alternative conflictingly named path templates are
/// specified. The one that matches is used to construct the header.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take the `table_name`, if it's well-formed, whether
///   // using the region- or projects-based syntax.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{table_name=regions/*/zones/*/**}"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "{table_name=projects/*/instances/*/**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// table_name=projects/proj_foo/instances/instance_bar/table/table_baz
/// ```
///
/// Example 4
///
/// Extracting a single routing header key-value pair by matching a
/// template syntax on (a part of) a single request field.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // Take just the project id from the `table_name` field.
///   routing_parameters {
///     field: "table_name"
///     path_template: "{routing_id=projects/*}/**"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params: routing_id=projects/proj_foo
/// ```
///
/// Example 5
///
/// Extracting a single routing header key-value pair by matching
/// several conflictingly named path templates on (parts of) a single request
/// field. The last template to match "wins" the conflict.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // If the `table_name` does not have instances information,
///   // take just the project id for routing.
///   // Otherwise take project + instance.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{routing_id=projects/*}/**"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "{routing_id=projects/*/instances/*}/**"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// routing_id=projects/proj_foo/instances/instance_bar
/// ```
///
/// Example 6
///
/// Extracting multiple routing header key-value pairs by matching
/// several non-conflicting path templates on (parts of) a single request field.
///
/// Sub-example 6a
///
/// Make the templates strict, so that if the `table_name` does not
/// have an instance information, nothing is sent.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // The routing code needs two keys instead of one composite
///   // but works only for the tables with the "project-instance" name
///   // syntax.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{project_id=projects/*}/instances/*/**"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "projects/*/{instance_id=instances/*}/**"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// project_id=projects/proj_foo&instance_id=instances/instance_bar
/// ```
///
/// Sub-example 6b
///
/// Make the templates loose, so that if the `table_name` does not
/// have an instance information, just the project id part is sent.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // The routing code wants two keys instead of one composite
///   // but will work with just the `project_id` for tables without
///   // an instance in the `table_name`.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{project_id=projects/*}/**"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "projects/*/{instance_id=instances/*}/**"
///   }
/// };
/// ```
///
/// result (is the same as 6a for our example message because it has the instance
/// information):
///
/// ```norust
/// x-goog-request-params:
/// project_id=projects/proj_foo&instance_id=instances/instance_bar
/// ```
///
/// Example 7
///
/// Extracting multiple routing header key-value pairs by matching
/// several path templates on multiple request fields.
///
/// NB: note that here there is no way to specify sending nothing if one of the
/// fields does not match its template. E.g. if the `table_name` is in the wrong
/// format, the `project_id` will not be sent, but the `routing_id` will be.
/// The backend routing code has to be aware of that and be prepared to not
/// receive a full complement of keys if it expects multiple.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // The routing needs both `project_id` and `routing_id`
///   // (from the `app_profile_id` field) for routing.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{project_id=projects/*}/**"
///   }
///   routing_parameters {
///     field: "app_profile_id"
///     path_template: "{routing_id=**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// project_id=projects/proj_foo&routing_id=profiles/prof_qux
/// ```
///
/// Example 8
///
/// Extracting a single routing header key-value pair by matching
/// several conflictingly named path templates on several request fields. The
/// last template to match "wins" the conflict.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // The `routing_id` can be a project id or a region id depending on
///   // the table name format, but only if the `app_profile_id` is not set.
///   // If `app_profile_id` is set it should be used instead.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "{routing_id=projects/*}/**"
///   }
///   routing_parameters {
///      field: "table_name"
///      path_template: "{routing_id=regions/*}/**"
///   }
///   routing_parameters {
///     field: "app_profile_id"
///     path_template: "{routing_id=**}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params: routing_id=profiles/prof_qux
/// ```
///
/// Example 9
///
/// Bringing it all together.
///
/// annotation:
///
/// ```norust
/// option (google.api.routing) = {
///   // For routing both `table_location` and a `routing_id` are needed.
///   //
///   // table_location can be either an instance id or a region+zone id.
///   //
///   // For `routing_id`, take the value of `app_profile_id`
///   // - If it's in the format `profiles/<profile_id>`, send
///   // just the `<profile_id>` part.
///   // - If it's any other literal, send it as is.
///   // If the `app_profile_id` is empty, and the `table_name` starts with
///   // the project_id, send that instead.
///
///   routing_parameters {
///     field: "table_name"
///     path_template: "projects/*/{table_location=instances/*}/tables/*"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "{table_location=regions/*/zones/*}/tables/*"
///   }
///   routing_parameters {
///     field: "table_name"
///     path_template: "{routing_id=projects/*}/**"
///   }
///   routing_parameters {
///     field: "app_profile_id"
///     path_template: "{routing_id=**}"
///   }
///   routing_parameters {
///     field: "app_profile_id"
///     path_template: "profiles/{routing_id=*}"
///   }
/// };
/// ```
///
/// result:
///
/// ```norust
/// x-goog-request-params:
/// table_location=instances/instance_bar&routing_id=prof_qux
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RoutingRule {
    /// A collection of Routing Parameter specifications.
    /// **NOTE:** If multiple Routing Parameters describe the same key
    /// (via the `path_template` field or via the `field` field when
    /// `path_template` is not provided), "last one wins" rule
    /// determines which Parameter gets used.
    /// See the examples for more details.
    pub routing_parameters: std::vec::Vec<crate::model::RoutingParameter>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RoutingRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [routing_parameters][crate::model::RoutingRule::routing_parameters].
    pub fn set_routing_parameters<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::RoutingParameter>,
    {
        use std::iter::Iterator;
        self.routing_parameters = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for RoutingRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.RoutingRule"
    }
}

/// A projection from an input message to the GRPC or REST header.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RoutingParameter {
    /// A request field to extract the header key-value pair from.
    pub field: std::string::String,

    /// A pattern matching the key-value field. Optional.
    /// If not specified, the whole field specified in the `field` field will be
    /// taken as value, and its name used as key. If specified, it MUST contain
    /// exactly one named segment (along with any number of unnamed segments) The
    /// pattern will be matched over the field specified in the `field` field, then
    /// if the match is successful:
    ///
    /// - the name of the single named segment will be used as a header name,
    /// - the match value of the segment will be used as a header value;
    ///   if the match is NOT successful, nothing will be sent.
    ///
    /// Example:
    ///
    /// ```norust
    ///           -- This is a field in the request message
    ///          |   that the header value will be extracted from.
    ///          |
    ///          |                     -- This is the key name in the
    ///          |                    |   routing header.
    ///          V                    |
    /// field: "table_name"           v
    /// path_template: "projects/*/{table_location=instances/*}/tables/*"
    ///                                            ^            ^
    ///                                            |            |
    ///   In the {} brackets is the pattern that --             |
    ///   specifies what to extract from the                    |
    ///   field as a value to be sent.                          |
    ///                                                         |
    ///  The string in the field must match the whole pattern --
    ///  before brackets, inside brackets, after brackets.
    /// ```
    ///
    /// When looking at this specific example, we can see that:
    ///
    /// - A key-value pair with the key `table_location`
    ///   and the value matching `instances/*` should be added
    ///   to the x-goog-request-params routing header.
    /// - The value is extracted from the request message's `table_name` field
    ///   if it matches the full pattern specified:
    ///   `projects/*/instances/*/tables/*`.
    ///
    /// **NB:** If the `path_template` field is not provided, the key name is
    /// equal to the field name, and the whole field should be sent as a value.
    /// This makes the pattern for the field and the value functionally equivalent
    /// to `**`, and the configuration
    ///
    /// ```norust
    /// {
    ///   field: "table_name"
    /// }
    /// ```
    ///
    /// is a functionally equivalent shorthand to:
    ///
    /// ```norust
    /// {
    ///   field: "table_name"
    ///   path_template: "{table_name=**}"
    /// }
    /// ```
    ///
    /// See Example 1 for more details.
    pub path_template: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RoutingParameter {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [field][crate::model::RoutingParameter::field].
    pub fn set_field<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.field = v.into();
        self
    }

    /// Sets the value of [path_template][crate::model::RoutingParameter::path_template].
    pub fn set_path_template<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.path_template = v.into();
        self
    }
}

impl wkt::message::Message for RoutingParameter {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.RoutingParameter"
    }
}

/// `Service` is the root object of Google API service configuration (service
/// config). It describes the basic information about a logical service,
/// such as the service name and the user-facing title, and delegates other
/// aspects to sub-sections. Each sub-section is either a proto message or a
/// repeated proto message that configures a specific aspect, such as auth.
/// For more information, see each proto message definition.
///
/// Example:
///
/// ```norust
/// type: google.api.Service
/// name: calendar.googleapis.com
/// title: Google Calendar API
/// apis:
/// - name: google.calendar.v3.Calendar
///
/// visibility:
///   rules:
///   - selector: "google.calendar.v3.*"
///     restriction: PREVIEW
/// backend:
///   rules:
///   - selector: "google.calendar.v3.*"
///     address: calendar.example.com
///
/// authentication:
///   providers:
///   - id: google_calendar_auth
///     jwks_uri: https://www.googleapis.com/oauth2/v1/certs
///     issuer: https://securetoken.google.com
///   rules:
///   - selector: "*"
///     requirements:
///       provider_id: google_calendar_auth
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Service {
    /// The service name, which is a DNS-like logical identifier for the
    /// service, such as `calendar.googleapis.com`. The service name
    /// typically goes through DNS verification to make sure the owner
    /// of the service also owns the DNS name.
    pub name: std::string::String,

    /// The product title for this service, it is the name displayed in Google
    /// Cloud Console.
    pub title: std::string::String,

    /// The Google project that owns this service.
    pub producer_project_id: std::string::String,

    /// A unique ID for a specific instance of this message, typically assigned
    /// by the client for tracking purpose. Must be no longer than 63 characters
    /// and only lower case letters, digits, '.', '_' and '-' are allowed. If
    /// empty, the server may choose to generate one instead.
    pub id: std::string::String,

    /// A list of API interfaces exported by this service. Only the `name` field
    /// of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by
    /// the configuration author, as the remaining fields will be derived from the
    /// IDL during the normalization process. It is an error to specify an API
    /// interface here which cannot be resolved against the associated IDL files.
    ///
    /// [google.protobuf.Api]: wkt::Api
    pub apis: std::vec::Vec<wkt::Api>,

    /// A list of all proto message types included in this API service.
    /// Types referenced directly or indirectly by the `apis` are automatically
    /// included.  Messages which are not referenced but shall be included, such as
    /// types used by the `google.protobuf.Any` type, should be listed here by
    /// name by the configuration author. Example:
    ///
    /// ```norust
    /// types:
    /// - name: google.protobuf.Int32
    /// ```
    pub types: std::vec::Vec<wkt::Type>,

    /// A list of all enum types included in this API service.  Enums referenced
    /// directly or indirectly by the `apis` are automatically included.  Enums
    /// which are not referenced but shall be included should be listed here by
    /// name by the configuration author. Example:
    ///
    /// ```norust
    /// enums:
    /// - name: google.someapi.v1.SomeEnum
    /// ```
    pub enums: std::vec::Vec<wkt::Enum>,

    /// Additional API documentation.
    pub documentation: std::option::Option<crate::model::Documentation>,

    /// API backend configuration.
    pub backend: std::option::Option<crate::model::Backend>,

    /// HTTP configuration.
    pub http: std::option::Option<crate::model::Http>,

    /// Quota configuration.
    pub quota: std::option::Option<crate::model::Quota>,

    /// Auth configuration.
    pub authentication: std::option::Option<crate::model::Authentication>,

    /// Context configuration.
    pub context: std::option::Option<crate::model::Context>,

    /// Configuration controlling usage of this service.
    pub usage: std::option::Option<crate::model::Usage>,

    /// Configuration for network endpoints.  If this is empty, then an endpoint
    /// with the same name as the service is automatically generated to service all
    /// defined APIs.
    pub endpoints: std::vec::Vec<crate::model::Endpoint>,

    /// Configuration for the service control plane.
    pub control: std::option::Option<crate::model::Control>,

    /// Defines the logs used by this service.
    pub logs: std::vec::Vec<crate::model::LogDescriptor>,

    /// Defines the metrics used by this service.
    pub metrics: std::vec::Vec<crate::model::MetricDescriptor>,

    /// Defines the monitored resources used by this service. This is required
    /// by the [Service.monitoring][google.api.Service.monitoring] and
    /// [Service.logging][google.api.Service.logging] configurations.
    ///
    /// [google.api.Service.logging]: crate::model::Service::logging
    /// [google.api.Service.monitoring]: crate::model::Service::monitoring
    pub monitored_resources: std::vec::Vec<crate::model::MonitoredResourceDescriptor>,

    /// Billing configuration.
    pub billing: std::option::Option<crate::model::Billing>,

    /// Logging configuration.
    pub logging: std::option::Option<crate::model::Logging>,

    /// Monitoring configuration.
    pub monitoring: std::option::Option<crate::model::Monitoring>,

    /// System parameter configuration.
    pub system_parameters: std::option::Option<crate::model::SystemParameters>,

    /// Output only. The source information for this configuration if available.
    pub source_info: std::option::Option<crate::model::SourceInfo>,

    /// Settings for [Google Cloud Client
    /// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries)
    /// generated from APIs defined as protocol buffers.
    pub publishing: std::option::Option<crate::model::Publishing>,

    /// Obsolete. Do not use.
    ///
    /// This field has no semantic meaning. The service config compiler always
    /// sets this field to `3`.
    pub config_version: std::option::Option<wkt::UInt32Value>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Service {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Service::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [title][crate::model::Service::title].
    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.title = v.into();
        self
    }

    /// Sets the value of [producer_project_id][crate::model::Service::producer_project_id].
    pub fn set_producer_project_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.producer_project_id = v.into();
        self
    }

    /// Sets the value of [id][crate::model::Service::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [apis][crate::model::Service::apis].
    pub fn set_apis<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Api>,
    {
        use std::iter::Iterator;
        self.apis = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [types][crate::model::Service::types].
    pub fn set_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Type>,
    {
        use std::iter::Iterator;
        self.types = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [enums][crate::model::Service::enums].
    pub fn set_enums<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Enum>,
    {
        use std::iter::Iterator;
        self.enums = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [documentation][crate::model::Service::documentation].
    pub fn set_documentation<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Documentation>,
    {
        self.documentation = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [documentation][crate::model::Service::documentation].
    pub fn set_or_clear_documentation<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Documentation>,
    {
        self.documentation = v.map(|x| x.into());
        self
    }

    /// Sets the value of [backend][crate::model::Service::backend].
    pub fn set_backend<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Backend>,
    {
        self.backend = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [backend][crate::model::Service::backend].
    pub fn set_or_clear_backend<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Backend>,
    {
        self.backend = v.map(|x| x.into());
        self
    }

    /// Sets the value of [http][crate::model::Service::http].
    pub fn set_http<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Http>,
    {
        self.http = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [http][crate::model::Service::http].
    pub fn set_or_clear_http<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Http>,
    {
        self.http = v.map(|x| x.into());
        self
    }

    /// Sets the value of [quota][crate::model::Service::quota].
    pub fn set_quota<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Quota>,
    {
        self.quota = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [quota][crate::model::Service::quota].
    pub fn set_or_clear_quota<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Quota>,
    {
        self.quota = v.map(|x| x.into());
        self
    }

    /// Sets the value of [authentication][crate::model::Service::authentication].
    pub fn set_authentication<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Authentication>,
    {
        self.authentication = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [authentication][crate::model::Service::authentication].
    pub fn set_or_clear_authentication<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Authentication>,
    {
        self.authentication = v.map(|x| x.into());
        self
    }

    /// Sets the value of [context][crate::model::Service::context].
    pub fn set_context<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Context>,
    {
        self.context = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [context][crate::model::Service::context].
    pub fn set_or_clear_context<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Context>,
    {
        self.context = v.map(|x| x.into());
        self
    }

    /// Sets the value of [usage][crate::model::Service::usage].
    pub fn set_usage<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Usage>,
    {
        self.usage = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [usage][crate::model::Service::usage].
    pub fn set_or_clear_usage<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Usage>,
    {
        self.usage = v.map(|x| x.into());
        self
    }

    /// Sets the value of [endpoints][crate::model::Service::endpoints].
    pub fn set_endpoints<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Endpoint>,
    {
        use std::iter::Iterator;
        self.endpoints = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [control][crate::model::Service::control].
    pub fn set_control<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Control>,
    {
        self.control = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [control][crate::model::Service::control].
    pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Control>,
    {
        self.control = v.map(|x| x.into());
        self
    }

    /// Sets the value of [logs][crate::model::Service::logs].
    pub fn set_logs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::LogDescriptor>,
    {
        use std::iter::Iterator;
        self.logs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [metrics][crate::model::Service::metrics].
    pub fn set_metrics<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MetricDescriptor>,
    {
        use std::iter::Iterator;
        self.metrics = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [monitored_resources][crate::model::Service::monitored_resources].
    pub fn set_monitored_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MonitoredResourceDescriptor>,
    {
        use std::iter::Iterator;
        self.monitored_resources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [billing][crate::model::Service::billing].
    pub fn set_billing<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Billing>,
    {
        self.billing = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [billing][crate::model::Service::billing].
    pub fn set_or_clear_billing<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Billing>,
    {
        self.billing = v.map(|x| x.into());
        self
    }

    /// Sets the value of [logging][crate::model::Service::logging].
    pub fn set_logging<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Logging>,
    {
        self.logging = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [logging][crate::model::Service::logging].
    pub fn set_or_clear_logging<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Logging>,
    {
        self.logging = v.map(|x| x.into());
        self
    }

    /// Sets the value of [monitoring][crate::model::Service::monitoring].
    pub fn set_monitoring<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Monitoring>,
    {
        self.monitoring = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [monitoring][crate::model::Service::monitoring].
    pub fn set_or_clear_monitoring<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Monitoring>,
    {
        self.monitoring = v.map(|x| x.into());
        self
    }

    /// Sets the value of [system_parameters][crate::model::Service::system_parameters].
    pub fn set_system_parameters<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::SystemParameters>,
    {
        self.system_parameters = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [system_parameters][crate::model::Service::system_parameters].
    pub fn set_or_clear_system_parameters<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::SystemParameters>,
    {
        self.system_parameters = v.map(|x| x.into());
        self
    }

    /// Sets the value of [source_info][crate::model::Service::source_info].
    pub fn set_source_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::SourceInfo>,
    {
        self.source_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [source_info][crate::model::Service::source_info].
    pub fn set_or_clear_source_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::SourceInfo>,
    {
        self.source_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [publishing][crate::model::Service::publishing].
    pub fn set_publishing<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Publishing>,
    {
        self.publishing = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [publishing][crate::model::Service::publishing].
    pub fn set_or_clear_publishing<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Publishing>,
    {
        self.publishing = v.map(|x| x.into());
        self
    }

    /// Sets the value of [config_version][crate::model::Service::config_version].
    pub fn set_config_version<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::UInt32Value>,
    {
        self.config_version = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [config_version][crate::model::Service::config_version].
    pub fn set_or_clear_config_version<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::UInt32Value>,
    {
        self.config_version = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for Service {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Service"
    }
}

/// Source information used to create a Service Config
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SourceInfo {
    /// All files used during config generation.
    pub source_files: std::vec::Vec<wkt::Any>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SourceInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [source_files][crate::model::SourceInfo::source_files].
    pub fn set_source_files<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<wkt::Any>,
    {
        use std::iter::Iterator;
        self.source_files = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for SourceInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.SourceInfo"
    }
}

/// ### System parameter configuration
///
/// A system parameter is a special kind of parameter defined by the API
/// system, not by an individual API. It is typically mapped to an HTTP header
/// and/or a URL query parameter. This configuration specifies which methods
/// change the names of the system parameters.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SystemParameters {
    /// Define system parameters.
    ///
    /// The parameters defined here will override the default parameters
    /// implemented by the system. If this field is missing from the service
    /// config, default system parameters will be used. Default system parameters
    /// and names is implementation-dependent.
    ///
    /// Example: define api key for all methods
    ///
    /// ```norust
    /// system_parameters
    ///   rules:
    ///     - selector: "*"
    ///       parameters:
    ///         - name: api_key
    ///           url_query_parameter: api_key
    /// ```
    ///
    /// Example: define 2 api key names for a specific method.
    ///
    /// ```norust
    /// system_parameters
    ///   rules:
    ///     - selector: "/ListShelves"
    ///       parameters:
    ///         - name: api_key
    ///           http_header: Api-Key1
    ///         - name: api_key
    ///           http_header: Api-Key2
    /// ```
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::SystemParameterRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SystemParameters {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::SystemParameters::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::SystemParameterRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for SystemParameters {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.SystemParameters"
    }
}

/// Define a system parameter rule mapping system parameter definitions to
/// methods.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SystemParameterRule {
    /// Selects the methods to which this rule applies. Use '*' to indicate all
    /// methods in all APIs.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// Define parameters. Multiple names may be defined for a parameter.
    /// For a given method call, only one of them should be used. If multiple
    /// names are used the behavior is implementation-dependent.
    /// If none of the specified names are present the behavior is
    /// parameter-dependent.
    pub parameters: std::vec::Vec<crate::model::SystemParameter>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SystemParameterRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::SystemParameterRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [parameters][crate::model::SystemParameterRule::parameters].
    pub fn set_parameters<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::SystemParameter>,
    {
        use std::iter::Iterator;
        self.parameters = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for SystemParameterRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.SystemParameterRule"
    }
}

/// Define a parameter's name and location. The parameter may be passed as either
/// an HTTP header or a URL query parameter, and if both are passed the behavior
/// is implementation-dependent.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SystemParameter {
    /// Define the name of the parameter, such as "api_key" . It is case sensitive.
    pub name: std::string::String,

    /// Define the HTTP header name to use for the parameter. It is case
    /// insensitive.
    pub http_header: std::string::String,

    /// Define the URL query parameter name to use for the parameter. It is case
    /// sensitive.
    pub url_query_parameter: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SystemParameter {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::SystemParameter::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [http_header][crate::model::SystemParameter::http_header].
    pub fn set_http_header<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.http_header = v.into();
        self
    }

    /// Sets the value of [url_query_parameter][crate::model::SystemParameter::url_query_parameter].
    pub fn set_url_query_parameter<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.url_query_parameter = v.into();
        self
    }
}

impl wkt::message::Message for SystemParameter {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.SystemParameter"
    }
}

/// Configuration controlling usage of a service.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Usage {
    /// Requirements that must be satisfied before a consumer project can use the
    /// service. Each requirement is of the form <service.name>/\<requirement-id\>;
    /// for example 'serviceusage.googleapis.com/billing-enabled'.
    ///
    /// For Google APIs, a Terms of Service requirement must be included here.
    /// Google Cloud APIs must include "serviceusage.googleapis.com/tos/cloud".
    /// Other Google APIs should include
    /// "serviceusage.googleapis.com/tos/universal". Additional ToS can be
    /// included based on the business needs.
    pub requirements: std::vec::Vec<std::string::String>,

    /// A list of usage rules that apply to individual API methods.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::UsageRule>,

    /// The full resource name of a channel used for sending notifications to the
    /// service producer.
    ///
    /// Google Service Management currently only supports
    /// [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification
    /// channel. To use Google Cloud Pub/Sub as the channel, this must be the name
    /// of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format
    /// documented in <https://cloud.google.com/pubsub/docs/overview>.
    pub producer_notification_channel: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Usage {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [requirements][crate::model::Usage::requirements].
    pub fn set_requirements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.requirements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [rules][crate::model::Usage::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::UsageRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [producer_notification_channel][crate::model::Usage::producer_notification_channel].
    pub fn set_producer_notification_channel<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.producer_notification_channel = v.into();
        self
    }
}

impl wkt::message::Message for Usage {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Usage"
    }
}

/// Usage configuration rules for the service.
///
/// NOTE: Under development.
///
/// Use this rule to configure unregistered calls for the service. Unregistered
/// calls are calls that do not contain consumer project identity.
/// (Example: calls that do not contain an API key).
/// By default, API methods do not allow unregistered calls, and each method call
/// must be identified by a consumer project identity. Use this rule to
/// allow/disallow unregistered calls.
///
/// Example of an API that wants to allow unregistered calls for entire service.
///
/// ```norust
/// usage:
///   rules:
///   - selector: "*"
///     allow_unregistered_calls: true
/// ```
///
/// Example of a method that wants to allow unregistered calls.
///
/// ```norust
/// usage:
///   rules:
///   - selector: "google.example.library.v1.LibraryService.CreateBook"
///     allow_unregistered_calls: true
/// ```
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UsageRule {
    /// Selects the methods to which this rule applies. Use '*' to indicate all
    /// methods in all APIs.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// If true, the selected method allows unregistered calls, e.g. calls
    /// that don't identify any user or application.
    pub allow_unregistered_calls: bool,

    /// If true, the selected method should skip service control and the control
    /// plane features, such as quota and billing, will not be available.
    /// This flag is used by Google Cloud Endpoints to bypass checks for internal
    /// methods, such as service health check methods.
    pub skip_service_control: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UsageRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::UsageRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [allow_unregistered_calls][crate::model::UsageRule::allow_unregistered_calls].
    pub fn set_allow_unregistered_calls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.allow_unregistered_calls = v.into();
        self
    }

    /// Sets the value of [skip_service_control][crate::model::UsageRule::skip_service_control].
    pub fn set_skip_service_control<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.skip_service_control = v.into();
        self
    }
}

impl wkt::message::Message for UsageRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.UsageRule"
    }
}

/// `Visibility` restricts service consumer's access to service elements,
/// such as whether an application can call a visibility-restricted method.
/// The restriction is expressed by applying visibility labels on service
/// elements. The visibility labels are elsewhere linked to service consumers.
///
/// A service can define multiple visibility labels, but a service consumer
/// should be granted at most one visibility label. Multiple visibility
/// labels for a single service consumer are not supported.
///
/// If an element and all its parents have no visibility label, its visibility
/// is unconditionally granted.
///
/// Example:
///
/// ```norust
/// visibility:
///   rules:
///   - selector: google.calendar.Calendar.EnhancedSearch
///     restriction: PREVIEW
///   - selector: google.calendar.Calendar.Delegate
///     restriction: INTERNAL
/// ```
///
/// Here, all methods are publicly visible except for the restricted methods
/// EnhancedSearch and Delegate.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Visibility {
    /// A list of visibility rules that apply to individual API elements.
    ///
    /// **NOTE:** All service configuration rules follow "last one wins" order.
    pub rules: std::vec::Vec<crate::model::VisibilityRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Visibility {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [rules][crate::model::Visibility::rules].
    pub fn set_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::VisibilityRule>,
    {
        use std::iter::Iterator;
        self.rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for Visibility {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.Visibility"
    }
}

/// A visibility rule provides visibility configuration for an individual API
/// element.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct VisibilityRule {
    /// Selects methods, messages, fields, enums, etc. to which this rule applies.
    ///
    /// Refer to [selector][google.api.DocumentationRule.selector] for syntax
    /// details.
    ///
    /// [google.api.DocumentationRule.selector]: crate::model::DocumentationRule::selector
    pub selector: std::string::String,

    /// A comma-separated list of visibility labels that apply to the `selector`.
    /// Any of the listed labels can be used to grant the visibility.
    ///
    /// If a rule has multiple labels, removing one of the labels but not all of
    /// them can break clients.
    ///
    /// Example:
    ///
    /// ```norust
    /// visibility:
    ///   rules:
    ///   - selector: google.calendar.Calendar.EnhancedSearch
    ///     restriction: INTERNAL, PREVIEW
    /// ```
    ///
    /// Removing INTERNAL from this restriction will break clients that rely on
    /// this method and only had access to it through INTERNAL.
    pub restriction: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl VisibilityRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [selector][crate::model::VisibilityRule::selector].
    pub fn set_selector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.selector = v.into();
        self
    }

    /// Sets the value of [restriction][crate::model::VisibilityRule::restriction].
    pub fn set_restriction<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.restriction = v.into();
        self
    }
}

impl wkt::message::Message for VisibilityRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.VisibilityRule"
    }
}

/// The organization for which the client libraries are being published.
/// Affects the url where generated docs are published, etc.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ClientLibraryOrganization {
    /// Not useful.
    Unspecified,
    /// Google Cloud Platform Org.
    Cloud,
    /// Ads (Advertising) Org.
    Ads,
    /// Photos Org.
    Photos,
    /// Street View Org.
    StreetView,
    /// Shopping Org.
    Shopping,
    /// Geo Org.
    Geo,
    /// Generative AI - <https://developers.generativeai.google>
    GenerativeAi,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ClientLibraryOrganization::value] or
    /// [ClientLibraryOrganization::name].
    UnknownValue(client_library_organization::UnknownValue),
}

#[doc(hidden)]
pub mod client_library_organization {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ClientLibraryOrganization {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Cloud => std::option::Option::Some(1),
            Self::Ads => std::option::Option::Some(2),
            Self::Photos => std::option::Option::Some(3),
            Self::StreetView => std::option::Option::Some(4),
            Self::Shopping => std::option::Option::Some(5),
            Self::Geo => std::option::Option::Some(6),
            Self::GenerativeAi => std::option::Option::Some(7),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => {
                std::option::Option::Some("CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED")
            }
            Self::Cloud => std::option::Option::Some("CLOUD"),
            Self::Ads => std::option::Option::Some("ADS"),
            Self::Photos => std::option::Option::Some("PHOTOS"),
            Self::StreetView => std::option::Option::Some("STREET_VIEW"),
            Self::Shopping => std::option::Option::Some("SHOPPING"),
            Self::Geo => std::option::Option::Some("GEO"),
            Self::GenerativeAi => std::option::Option::Some("GENERATIVE_AI"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ClientLibraryOrganization {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ClientLibraryOrganization {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ClientLibraryOrganization {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Cloud,
            2 => Self::Ads,
            3 => Self::Photos,
            4 => Self::StreetView,
            5 => Self::Shopping,
            6 => Self::Geo,
            7 => Self::GenerativeAi,
            _ => Self::UnknownValue(client_library_organization::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ClientLibraryOrganization {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED" => Self::Unspecified,
            "CLOUD" => Self::Cloud,
            "ADS" => Self::Ads,
            "PHOTOS" => Self::Photos,
            "STREET_VIEW" => Self::StreetView,
            "SHOPPING" => Self::Shopping,
            "GEO" => Self::Geo,
            "GENERATIVE_AI" => Self::GenerativeAi,
            _ => Self::UnknownValue(client_library_organization::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ClientLibraryOrganization {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Cloud => serializer.serialize_i32(1),
            Self::Ads => serializer.serialize_i32(2),
            Self::Photos => serializer.serialize_i32(3),
            Self::StreetView => serializer.serialize_i32(4),
            Self::Shopping => serializer.serialize_i32(5),
            Self::Geo => serializer.serialize_i32(6),
            Self::GenerativeAi => serializer.serialize_i32(7),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ClientLibraryOrganization {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(
            wkt::internal::EnumVisitor::<ClientLibraryOrganization>::new(
                ".google.api.ClientLibraryOrganization",
            ),
        )
    }
}

/// To where should client libraries be published?
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ClientLibraryDestination {
    /// Client libraries will neither be generated nor published to package
    /// managers.
    Unspecified,
    /// Generate the client library in a repo under github.com/googleapis,
    /// but don't publish it to package managers.
    Github,
    /// Publish the library to package managers like nuget.org and npmjs.com.
    PackageManager,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ClientLibraryDestination::value] or
    /// [ClientLibraryDestination::name].
    UnknownValue(client_library_destination::UnknownValue),
}

#[doc(hidden)]
pub mod client_library_destination {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ClientLibraryDestination {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Github => std::option::Option::Some(10),
            Self::PackageManager => std::option::Option::Some(20),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => {
                std::option::Option::Some("CLIENT_LIBRARY_DESTINATION_UNSPECIFIED")
            }
            Self::Github => std::option::Option::Some("GITHUB"),
            Self::PackageManager => std::option::Option::Some("PACKAGE_MANAGER"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ClientLibraryDestination {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ClientLibraryDestination {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ClientLibraryDestination {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            10 => Self::Github,
            20 => Self::PackageManager,
            _ => Self::UnknownValue(client_library_destination::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ClientLibraryDestination {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED" => Self::Unspecified,
            "GITHUB" => Self::Github,
            "PACKAGE_MANAGER" => Self::PackageManager,
            _ => Self::UnknownValue(client_library_destination::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ClientLibraryDestination {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Github => serializer.serialize_i32(10),
            Self::PackageManager => serializer.serialize_i32(20),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ClientLibraryDestination {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ClientLibraryDestination>::new(
            ".google.api.ClientLibraryDestination",
        ))
    }
}

/// Classifies set of possible modifications to an object in the service
/// configuration.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ChangeType {
    /// No value was provided.
    Unspecified,
    /// The changed object exists in the 'new' service configuration, but not
    /// in the 'old' service configuration.
    Added,
    /// The changed object exists in the 'old' service configuration, but not
    /// in the 'new' service configuration.
    Removed,
    /// The changed object exists in both service configurations, but its value
    /// is different.
    Modified,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ChangeType::value] or
    /// [ChangeType::name].
    UnknownValue(change_type::UnknownValue),
}

#[doc(hidden)]
pub mod change_type {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ChangeType {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Added => std::option::Option::Some(1),
            Self::Removed => std::option::Option::Some(2),
            Self::Modified => std::option::Option::Some(3),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("CHANGE_TYPE_UNSPECIFIED"),
            Self::Added => std::option::Option::Some("ADDED"),
            Self::Removed => std::option::Option::Some("REMOVED"),
            Self::Modified => std::option::Option::Some("MODIFIED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ChangeType {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ChangeType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ChangeType {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Added,
            2 => Self::Removed,
            3 => Self::Modified,
            _ => Self::UnknownValue(change_type::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ChangeType {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "CHANGE_TYPE_UNSPECIFIED" => Self::Unspecified,
            "ADDED" => Self::Added,
            "REMOVED" => Self::Removed,
            "MODIFIED" => Self::Modified,
            _ => Self::UnknownValue(change_type::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ChangeType {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Added => serializer.serialize_i32(1),
            Self::Removed => serializer.serialize_i32(2),
            Self::Modified => serializer.serialize_i32(3),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ChangeType {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ChangeType>::new(
            ".google.api.ChangeType",
        ))
    }
}

/// Defines the supported values for `google.rpc.ErrorInfo.reason` for the
/// `googleapis.com` error domain. This error domain is reserved for [Service
/// Infrastructure](https://cloud.google.com/service-infrastructure/docs/overview).
/// For each error info of this domain, the metadata key "service" refers to the
/// logical identifier of an API service, such as "pubsub.googleapis.com". The
/// "consumer" refers to the entity that consumes an API Service. It typically is
/// a Google project that owns the client application or the server resource,
/// such as "projects/123". Other metadata keys are specific to each error
/// reason. For more information, see the definition of the specific error
/// reason.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ErrorReason {
    /// Do not use this default value.
    Unspecified,
    /// The request is calling a disabled service for a consumer.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" contacting
    /// "pubsub.googleapis.com" service which is disabled:
    ///
    /// ```norust
    /// { "reason": "SERVICE_DISABLED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "pubsub.googleapis.com"
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates the "pubsub.googleapis.com" has been disabled in
    /// "projects/123".
    ServiceDisabled,
    /// The request whose associated billing account is disabled.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
    /// "pubsub.googleapis.com" service because the associated billing account is
    /// disabled:
    ///
    /// ```norust
    /// { "reason": "BILLING_DISABLED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "pubsub.googleapis.com"
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates the billing account associated has been disabled.
    BillingDisabled,
    /// The request is denied because the provided [API
    /// key](https://cloud.google.com/docs/authentication/api-keys) is invalid. It
    /// may be in a bad format, cannot be found, or has been expired).
    ///
    /// Example of an ErrorInfo when the request is contacting
    /// "storage.googleapis.com" service with an invalid API key:
    ///
    /// ```norust
    /// { "reason": "API_KEY_INVALID",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///   }
    /// }
    /// ```
    ApiKeyInvalid,
    /// The request is denied because it violates [API key API
    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_api_restrictions).
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call the
    /// "storage.googleapis.com" service because this service is restricted in the
    /// API key:
    ///
    /// ```norust
    /// { "reason": "API_KEY_SERVICE_BLOCKED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ApiKeyServiceBlocked,
    /// The request is denied because it violates [API key HTTP
    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions).
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
    /// "storage.googleapis.com" service because the http referrer of the request
    /// violates API key HTTP restrictions:
    ///
    /// ```norust
    /// { "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com",
    ///   }
    /// }
    /// ```
    ApiKeyHttpReferrerBlocked,
    /// The request is denied because it violates [API key IP address
    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
    /// "storage.googleapis.com" service because the caller IP of the request
    /// violates API key IP address restrictions:
    ///
    /// ```norust
    /// { "reason": "API_KEY_IP_ADDRESS_BLOCKED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com",
    ///   }
    /// }
    /// ```
    ApiKeyIpAddressBlocked,
    /// The request is denied because it violates [API key Android application
    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
    /// "storage.googleapis.com" service because the request from the Android apps
    /// violates the API key Android application restrictions:
    ///
    /// ```norust
    /// { "reason": "API_KEY_ANDROID_APP_BLOCKED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ApiKeyAndroidAppBlocked,
    /// The request is denied because it violates [API key iOS application
    /// restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions).
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
    /// "storage.googleapis.com" service because the request from the iOS apps
    /// violates the API key iOS application restrictions:
    ///
    /// ```norust
    /// { "reason": "API_KEY_IOS_APP_BLOCKED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ApiKeyIosAppBlocked,
    /// The request is denied because there is not enough rate quota for the
    /// consumer.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
    /// "pubsub.googleapis.com" service because consumer's rate quota usage has
    /// reached the maximum value set for the quota limit
    /// "ReadsPerMinutePerProject" on the quota metric
    /// "pubsub.googleapis.com/read_requests":
    ///
    /// ```norust
    /// { "reason": "RATE_LIMIT_EXCEEDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "pubsub.googleapis.com",
    ///     "quota_metric": "pubsub.googleapis.com/read_requests",
    ///     "quota_limit": "ReadsPerMinutePerProject"
    ///   }
    /// }
    /// ```
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" checks quota on
    /// the service "dataflow.googleapis.com" and hits the organization quota
    /// limit "DefaultRequestsPerMinutePerOrganization" on the metric
    /// "dataflow.googleapis.com/default_requests".
    ///
    /// ```norust
    /// { "reason": "RATE_LIMIT_EXCEEDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "dataflow.googleapis.com",
    ///     "quota_metric": "dataflow.googleapis.com/default_requests",
    ///     "quota_limit": "DefaultRequestsPerMinutePerOrganization"
    ///   }
    /// }
    /// ```
    RateLimitExceeded,
    /// The request is denied because there is not enough resource quota for the
    /// consumer.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
    /// "compute.googleapis.com" service because consumer's resource quota usage
    /// has reached the maximum value set for the quota limit "VMsPerProject"
    /// on the quota metric "compute.googleapis.com/vms":
    ///
    /// ```norust
    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "compute.googleapis.com",
    ///     "quota_metric": "compute.googleapis.com/vms",
    ///     "quota_limit": "VMsPerProject"
    ///   }
    /// }
    /// ```
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" checks resource
    /// quota on the service "dataflow.googleapis.com" and hits the organization
    /// quota limit "jobs-per-organization" on the metric
    /// "dataflow.googleapis.com/job_count".
    ///
    /// ```norust
    /// { "reason": "RESOURCE_QUOTA_EXCEEDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "dataflow.googleapis.com",
    ///     "quota_metric": "dataflow.googleapis.com/job_count",
    ///     "quota_limit": "jobs-per-organization"
    ///   }
    /// }
    /// ```
    ResourceQuotaExceeded,
    /// The request whose associated billing account address is in a tax restricted
    /// location, violates the local tax restrictions when creating resources in
    /// the restricted region.
    ///
    /// Example of an ErrorInfo when creating the Cloud Storage Bucket in the
    /// container "projects/123" under a tax restricted region
    /// "locations/asia-northeast3":
    ///
    /// ```norust
    /// { "reason": "LOCATION_TAX_POLICY_VIOLATED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com",
    ///     "location": "locations/asia-northeast3"
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates creating the Cloud Storage Bucket in
    /// "locations/asia-northeast3" violates the location tax restriction.
    LocationTaxPolicyViolated,
    /// The request is denied because the caller does not have required permission
    /// on the user project "projects/123" or the user project is invalid. For more
    /// information, check the [userProject System
    /// Parameters](https://cloud.google.com/apis/docs/system-parameters).
    ///
    /// Example of an ErrorInfo when the caller is calling Cloud Storage service
    /// with insufficient permissions on the user project:
    ///
    /// ```norust
    /// { "reason": "USER_PROJECT_DENIED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    UserProjectDenied,
    /// The request is denied because the consumer "projects/123" is suspended due
    /// to Terms of Service(Tos) violations. Check [Project suspension
    /// guidelines](https://cloud.google.com/resource-manager/docs/project-suspension-guidelines)
    /// for more information.
    ///
    /// Example of an ErrorInfo when calling Cloud Storage service with the
    /// suspended consumer "projects/123":
    ///
    /// ```norust
    /// { "reason": "CONSUMER_SUSPENDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ConsumerSuspended,
    /// The request is denied because the associated consumer is invalid. It may be
    /// in a bad format, cannot be found, or have been deleted.
    ///
    /// Example of an ErrorInfo when calling Cloud Storage service with the
    /// invalid consumer "projects/123":
    ///
    /// ```norust
    /// { "reason": "CONSUMER_INVALID",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ConsumerInvalid,
    /// The request is denied because it violates [VPC Service
    /// Controls](https://cloud.google.com/vpc-service-controls/docs/overview).
    /// The 'uid' field is a random generated identifier that customer can use it
    /// to search the audit log for a request rejected by VPC Service Controls. For
    /// more information, please refer [VPC Service Controls
    /// Troubleshooting](https://cloud.google.com/vpc-service-controls/docs/troubleshooting#unique-id)
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to call
    /// Cloud Storage service because the request is prohibited by the VPC Service
    /// Controls.
    ///
    /// ```norust
    /// { "reason": "SECURITY_POLICY_VIOLATED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "uid": "123456789abcde",
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    SecurityPolicyViolated,
    /// The request is denied because the provided access token has expired.
    ///
    /// Example of an ErrorInfo when the request is calling Cloud Storage service
    /// with an expired access token:
    ///
    /// ```norust
    /// { "reason": "ACCESS_TOKEN_EXPIRED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject"
    ///   }
    /// }
    /// ```
    AccessTokenExpired,
    /// The request is denied because the provided access token doesn't have at
    /// least one of the acceptable scopes required for the API. Please check
    /// [OAuth 2.0 Scopes for Google
    /// APIs](https://developers.google.com/identity/protocols/oauth2/scopes) for
    /// the list of the OAuth 2.0 scopes that you might need to request to access
    /// the API.
    ///
    /// Example of an ErrorInfo when the request is calling Cloud Storage service
    /// with an access token that is missing required scopes:
    ///
    /// ```norust
    /// { "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject"
    ///   }
    /// }
    /// ```
    AccessTokenScopeInsufficient,
    /// The request is denied because the account associated with the provided
    /// access token is in an invalid state, such as disabled or deleted.
    /// For more information, see <https://cloud.google.com/docs/authentication>.
    ///
    /// Warning: For privacy reasons, the server may not be able to disclose the
    /// email address for some accounts. The client MUST NOT depend on the
    /// availability of the `email` attribute.
    ///
    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
    /// an access token that is associated with a disabled or deleted [service
    /// account](http://cloud/iam/docs/service-accounts):
    ///
    /// ```norust
    /// { "reason": "ACCOUNT_STATE_INVALID",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject",
    ///     "email": "user@123.iam.gserviceaccount.com"
    ///   }
    /// }
    /// ```
    AccountStateInvalid,
    /// The request is denied because the type of the provided access token is not
    /// supported by the API being called.
    ///
    /// Example of an ErrorInfo when the request is to the Cloud Storage API with
    /// an unsupported token type.
    ///
    /// ```norust
    /// { "reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject"
    ///   }
    /// }
    /// ```
    AccessTokenTypeUnsupported,
    /// The request is denied because the request doesn't have any authentication
    /// credentials. For more information regarding the supported authentication
    /// strategies for Google Cloud APIs, see
    /// <https://cloud.google.com/docs/authentication>.
    ///
    /// Example of an ErrorInfo when the request is to the Cloud Storage API
    /// without any authentication credentials.
    ///
    /// ```norust
    /// { "reason": "CREDENTIALS_MISSING",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject"
    ///   }
    /// }
    /// ```
    CredentialsMissing,
    /// The request is denied because the provided project owning the resource
    /// which acts as the [API
    /// consumer](https://cloud.google.com/apis/design/glossary#api_consumer) is
    /// invalid. It may be in a bad format or empty.
    ///
    /// Example of an ErrorInfo when the request is to the Cloud Functions API,
    /// but the offered resource project in the request in a bad format which can't
    /// perform the ListFunctions method.
    ///
    /// ```norust
    /// { "reason": "RESOURCE_PROJECT_INVALID",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "cloudfunctions.googleapis.com",
    ///     "method":
    ///     "google.cloud.functions.v1.CloudFunctionsService.ListFunctions"
    ///   }
    /// }
    /// ```
    ResourceProjectInvalid,
    /// The request is denied because the provided session cookie is missing,
    /// invalid or failed to decode.
    ///
    /// Example of an ErrorInfo when the request is calling Cloud Storage service
    /// with a SID cookie which can't be decoded.
    ///
    /// ```norust
    /// { "reason": "SESSION_COOKIE_INVALID",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject",
    ///     "cookie": "SID"
    ///   }
    /// }
    /// ```
    SessionCookieInvalid,
    /// The request is denied because the user is from a Google Workspace customer
    /// that blocks their users from accessing a particular service.
    ///
    /// Example scenario: <https://support.google.com/a/answer/9197205?hl=en>
    ///
    /// Example of an ErrorInfo when access to Google Cloud Storage service is
    /// blocked by the Google Workspace administrator:
    ///
    /// ```norust
    /// { "reason": "USER_BLOCKED_BY_ADMIN",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "storage.googleapis.com",
    ///     "method": "google.storage.v1.Storage.GetObject",
    ///   }
    /// }
    /// ```
    UserBlockedByAdmin,
    /// The request is denied because the resource service usage is restricted
    /// by administrators according to the organization policy constraint.
    /// For more information see
    /// <https://cloud.google.com/resource-manager/docs/organization-policy/restricting-services>.
    ///
    /// Example of an ErrorInfo when access to Google Cloud Storage service is
    /// restricted by Resource Usage Restriction policy:
    ///
    /// ```norust
    /// { "reason": "RESOURCE_USAGE_RESTRICTION_VIOLATED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/project-123",
    ///     "service": "storage.googleapis.com"
    ///   }
    /// }
    /// ```
    ResourceUsageRestrictionViolated,
    /// Unimplemented. Do not use.
    ///
    /// The request is denied because it contains unsupported system parameters in
    /// URL query parameters or HTTP headers. For more information,
    /// see <https://cloud.google.com/apis/docs/system-parameters>
    ///
    /// Example of an ErrorInfo when access "pubsub.googleapis.com" service with
    /// a request header of "x-goog-user-ip":
    ///
    /// ```norust
    /// { "reason": "SYSTEM_PARAMETER_UNSUPPORTED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "service": "pubsub.googleapis.com"
    ///     "parameter": "x-goog-user-ip"
    ///   }
    /// }
    /// ```
    SystemParameterUnsupported,
    /// The request is denied because it violates Org Restriction: the requested
    /// resource does not belong to allowed organizations specified in
    /// "X-Goog-Allowed-Resources" header.
    ///
    /// Example of an ErrorInfo when accessing a GCP resource that is restricted by
    /// Org Restriction for "pubsub.googleapis.com" service.
    ///
    /// {
    /// reason: "ORG_RESTRICTION_VIOLATION"
    /// domain: "googleapis.com"
    /// metadata {
    /// "consumer":"projects/123456"
    /// "service": "pubsub.googleapis.com"
    /// }
    /// }
    OrgRestrictionViolation,
    /// The request is denied because "X-Goog-Allowed-Resources" header is in a bad
    /// format.
    ///
    /// Example of an ErrorInfo when
    /// accessing "pubsub.googleapis.com" service with an invalid
    /// "X-Goog-Allowed-Resources" request header.
    ///
    /// {
    /// reason: "ORG_RESTRICTION_HEADER_INVALID"
    /// domain: "googleapis.com"
    /// metadata {
    /// "consumer":"projects/123456"
    /// "service": "pubsub.googleapis.com"
    /// }
    /// }
    OrgRestrictionHeaderInvalid,
    /// Unimplemented. Do not use.
    ///
    /// The request is calling a service that is not visible to the consumer.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" contacting
    /// "pubsub.googleapis.com" service which is not visible to the consumer.
    ///
    /// ```norust
    /// { "reason": "SERVICE_NOT_VISIBLE",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "pubsub.googleapis.com"
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates the "pubsub.googleapis.com" is not visible to
    /// "projects/123" (or it may not exist).
    ServiceNotVisible,
    /// The request is related to a project for which GCP access is suspended.
    ///
    /// Example of an ErrorInfo when the consumer "projects/123" fails to contact
    /// "pubsub.googleapis.com" service because GCP access is suspended:
    ///
    /// ```norust
    /// { "reason": "GCP_SUSPENDED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "pubsub.googleapis.com"
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates the associated GCP account has been suspended.
    GcpSuspended,
    /// The request violates the location policies when creating resources in
    /// the restricted region.
    ///
    /// Example of an ErrorInfo when creating the Cloud Storage Bucket by
    /// "projects/123" for service storage.googleapis.com:
    ///
    /// ```norust
    /// { "reason": "LOCATION_POLICY_VIOLATED",
    ///   "domain": "googleapis.com",
    ///   "metadata": {
    ///     "consumer": "projects/123",
    ///     "service": "storage.googleapis.com",
    ///   }
    /// }
    /// ```
    ///
    /// This response indicates creating the Cloud Storage Bucket in
    /// "locations/asia-northeast3" violates at least one location policy.
    /// The troubleshooting guidance is provided in the Help links.
    LocationPolicyViolated,
    /// The request is denied because origin request header is missing.
    ///
    /// Example of an ErrorInfo when
    /// accessing "pubsub.googleapis.com" service with an empty "Origin" request
    /// header.
    ///
    /// {
    /// reason: "MISSING_ORIGIN"
    /// domain: "googleapis.com"
    /// metadata {
    /// "consumer":"projects/123456"
    /// "service": "pubsub.googleapis.com"
    /// }
    /// }
    MissingOrigin,
    /// The request is denied because the request contains more than one credential
    /// type that are individually acceptable, but not together. The customer
    /// should retry their request with only one set of credentials.
    ///
    /// Example of an ErrorInfo when
    /// accessing "pubsub.googleapis.com" service with overloaded credentials.
    ///
    /// {
    /// reason: "OVERLOADED_CREDENTIALS"
    /// domain: "googleapis.com"
    /// metadata {
    /// "consumer":"projects/123456"
    /// "service": "pubsub.googleapis.com"
    /// }
    /// }
    OverloadedCredentials,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ErrorReason::value] or
    /// [ErrorReason::name].
    UnknownValue(error_reason::UnknownValue),
}

#[doc(hidden)]
pub mod error_reason {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ErrorReason {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::ServiceDisabled => std::option::Option::Some(1),
            Self::BillingDisabled => std::option::Option::Some(2),
            Self::ApiKeyInvalid => std::option::Option::Some(3),
            Self::ApiKeyServiceBlocked => std::option::Option::Some(4),
            Self::ApiKeyHttpReferrerBlocked => std::option::Option::Some(7),
            Self::ApiKeyIpAddressBlocked => std::option::Option::Some(8),
            Self::ApiKeyAndroidAppBlocked => std::option::Option::Some(9),
            Self::ApiKeyIosAppBlocked => std::option::Option::Some(13),
            Self::RateLimitExceeded => std::option::Option::Some(5),
            Self::ResourceQuotaExceeded => std::option::Option::Some(6),
            Self::LocationTaxPolicyViolated => std::option::Option::Some(10),
            Self::UserProjectDenied => std::option::Option::Some(11),
            Self::ConsumerSuspended => std::option::Option::Some(12),
            Self::ConsumerInvalid => std::option::Option::Some(14),
            Self::SecurityPolicyViolated => std::option::Option::Some(15),
            Self::AccessTokenExpired => std::option::Option::Some(16),
            Self::AccessTokenScopeInsufficient => std::option::Option::Some(17),
            Self::AccountStateInvalid => std::option::Option::Some(18),
            Self::AccessTokenTypeUnsupported => std::option::Option::Some(19),
            Self::CredentialsMissing => std::option::Option::Some(20),
            Self::ResourceProjectInvalid => std::option::Option::Some(21),
            Self::SessionCookieInvalid => std::option::Option::Some(23),
            Self::UserBlockedByAdmin => std::option::Option::Some(24),
            Self::ResourceUsageRestrictionViolated => std::option::Option::Some(25),
            Self::SystemParameterUnsupported => std::option::Option::Some(26),
            Self::OrgRestrictionViolation => std::option::Option::Some(27),
            Self::OrgRestrictionHeaderInvalid => std::option::Option::Some(28),
            Self::ServiceNotVisible => std::option::Option::Some(29),
            Self::GcpSuspended => std::option::Option::Some(30),
            Self::LocationPolicyViolated => std::option::Option::Some(31),
            Self::MissingOrigin => std::option::Option::Some(33),
            Self::OverloadedCredentials => std::option::Option::Some(34),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("ERROR_REASON_UNSPECIFIED"),
            Self::ServiceDisabled => std::option::Option::Some("SERVICE_DISABLED"),
            Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
            Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
            Self::ApiKeyServiceBlocked => std::option::Option::Some("API_KEY_SERVICE_BLOCKED"),
            Self::ApiKeyHttpReferrerBlocked => {
                std::option::Option::Some("API_KEY_HTTP_REFERRER_BLOCKED")
            }
            Self::ApiKeyIpAddressBlocked => std::option::Option::Some("API_KEY_IP_ADDRESS_BLOCKED"),
            Self::ApiKeyAndroidAppBlocked => {
                std::option::Option::Some("API_KEY_ANDROID_APP_BLOCKED")
            }
            Self::ApiKeyIosAppBlocked => std::option::Option::Some("API_KEY_IOS_APP_BLOCKED"),
            Self::RateLimitExceeded => std::option::Option::Some("RATE_LIMIT_EXCEEDED"),
            Self::ResourceQuotaExceeded => std::option::Option::Some("RESOURCE_QUOTA_EXCEEDED"),
            Self::LocationTaxPolicyViolated => {
                std::option::Option::Some("LOCATION_TAX_POLICY_VIOLATED")
            }
            Self::UserProjectDenied => std::option::Option::Some("USER_PROJECT_DENIED"),
            Self::ConsumerSuspended => std::option::Option::Some("CONSUMER_SUSPENDED"),
            Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
            Self::SecurityPolicyViolated => std::option::Option::Some("SECURITY_POLICY_VIOLATED"),
            Self::AccessTokenExpired => std::option::Option::Some("ACCESS_TOKEN_EXPIRED"),
            Self::AccessTokenScopeInsufficient => {
                std::option::Option::Some("ACCESS_TOKEN_SCOPE_INSUFFICIENT")
            }
            Self::AccountStateInvalid => std::option::Option::Some("ACCOUNT_STATE_INVALID"),
            Self::AccessTokenTypeUnsupported => {
                std::option::Option::Some("ACCESS_TOKEN_TYPE_UNSUPPORTED")
            }
            Self::CredentialsMissing => std::option::Option::Some("CREDENTIALS_MISSING"),
            Self::ResourceProjectInvalid => std::option::Option::Some("RESOURCE_PROJECT_INVALID"),
            Self::SessionCookieInvalid => std::option::Option::Some("SESSION_COOKIE_INVALID"),
            Self::UserBlockedByAdmin => std::option::Option::Some("USER_BLOCKED_BY_ADMIN"),
            Self::ResourceUsageRestrictionViolated => {
                std::option::Option::Some("RESOURCE_USAGE_RESTRICTION_VIOLATED")
            }
            Self::SystemParameterUnsupported => {
                std::option::Option::Some("SYSTEM_PARAMETER_UNSUPPORTED")
            }
            Self::OrgRestrictionViolation => std::option::Option::Some("ORG_RESTRICTION_VIOLATION"),
            Self::OrgRestrictionHeaderInvalid => {
                std::option::Option::Some("ORG_RESTRICTION_HEADER_INVALID")
            }
            Self::ServiceNotVisible => std::option::Option::Some("SERVICE_NOT_VISIBLE"),
            Self::GcpSuspended => std::option::Option::Some("GCP_SUSPENDED"),
            Self::LocationPolicyViolated => std::option::Option::Some("LOCATION_POLICY_VIOLATED"),
            Self::MissingOrigin => std::option::Option::Some("MISSING_ORIGIN"),
            Self::OverloadedCredentials => std::option::Option::Some("OVERLOADED_CREDENTIALS"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ErrorReason {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ErrorReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ErrorReason {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::ServiceDisabled,
            2 => Self::BillingDisabled,
            3 => Self::ApiKeyInvalid,
            4 => Self::ApiKeyServiceBlocked,
            5 => Self::RateLimitExceeded,
            6 => Self::ResourceQuotaExceeded,
            7 => Self::ApiKeyHttpReferrerBlocked,
            8 => Self::ApiKeyIpAddressBlocked,
            9 => Self::ApiKeyAndroidAppBlocked,
            10 => Self::LocationTaxPolicyViolated,
            11 => Self::UserProjectDenied,
            12 => Self::ConsumerSuspended,
            13 => Self::ApiKeyIosAppBlocked,
            14 => Self::ConsumerInvalid,
            15 => Self::SecurityPolicyViolated,
            16 => Self::AccessTokenExpired,
            17 => Self::AccessTokenScopeInsufficient,
            18 => Self::AccountStateInvalid,
            19 => Self::AccessTokenTypeUnsupported,
            20 => Self::CredentialsMissing,
            21 => Self::ResourceProjectInvalid,
            23 => Self::SessionCookieInvalid,
            24 => Self::UserBlockedByAdmin,
            25 => Self::ResourceUsageRestrictionViolated,
            26 => Self::SystemParameterUnsupported,
            27 => Self::OrgRestrictionViolation,
            28 => Self::OrgRestrictionHeaderInvalid,
            29 => Self::ServiceNotVisible,
            30 => Self::GcpSuspended,
            31 => Self::LocationPolicyViolated,
            33 => Self::MissingOrigin,
            34 => Self::OverloadedCredentials,
            _ => Self::UnknownValue(error_reason::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ErrorReason {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "ERROR_REASON_UNSPECIFIED" => Self::Unspecified,
            "SERVICE_DISABLED" => Self::ServiceDisabled,
            "BILLING_DISABLED" => Self::BillingDisabled,
            "API_KEY_INVALID" => Self::ApiKeyInvalid,
            "API_KEY_SERVICE_BLOCKED" => Self::ApiKeyServiceBlocked,
            "API_KEY_HTTP_REFERRER_BLOCKED" => Self::ApiKeyHttpReferrerBlocked,
            "API_KEY_IP_ADDRESS_BLOCKED" => Self::ApiKeyIpAddressBlocked,
            "API_KEY_ANDROID_APP_BLOCKED" => Self::ApiKeyAndroidAppBlocked,
            "API_KEY_IOS_APP_BLOCKED" => Self::ApiKeyIosAppBlocked,
            "RATE_LIMIT_EXCEEDED" => Self::RateLimitExceeded,
            "RESOURCE_QUOTA_EXCEEDED" => Self::ResourceQuotaExceeded,
            "LOCATION_TAX_POLICY_VIOLATED" => Self::LocationTaxPolicyViolated,
            "USER_PROJECT_DENIED" => Self::UserProjectDenied,
            "CONSUMER_SUSPENDED" => Self::ConsumerSuspended,
            "CONSUMER_INVALID" => Self::ConsumerInvalid,
            "SECURITY_POLICY_VIOLATED" => Self::SecurityPolicyViolated,
            "ACCESS_TOKEN_EXPIRED" => Self::AccessTokenExpired,
            "ACCESS_TOKEN_SCOPE_INSUFFICIENT" => Self::AccessTokenScopeInsufficient,
            "ACCOUNT_STATE_INVALID" => Self::AccountStateInvalid,
            "ACCESS_TOKEN_TYPE_UNSUPPORTED" => Self::AccessTokenTypeUnsupported,
            "CREDENTIALS_MISSING" => Self::CredentialsMissing,
            "RESOURCE_PROJECT_INVALID" => Self::ResourceProjectInvalid,
            "SESSION_COOKIE_INVALID" => Self::SessionCookieInvalid,
            "USER_BLOCKED_BY_ADMIN" => Self::UserBlockedByAdmin,
            "RESOURCE_USAGE_RESTRICTION_VIOLATED" => Self::ResourceUsageRestrictionViolated,
            "SYSTEM_PARAMETER_UNSUPPORTED" => Self::SystemParameterUnsupported,
            "ORG_RESTRICTION_VIOLATION" => Self::OrgRestrictionViolation,
            "ORG_RESTRICTION_HEADER_INVALID" => Self::OrgRestrictionHeaderInvalid,
            "SERVICE_NOT_VISIBLE" => Self::ServiceNotVisible,
            "GCP_SUSPENDED" => Self::GcpSuspended,
            "LOCATION_POLICY_VIOLATED" => Self::LocationPolicyViolated,
            "MISSING_ORIGIN" => Self::MissingOrigin,
            "OVERLOADED_CREDENTIALS" => Self::OverloadedCredentials,
            _ => Self::UnknownValue(error_reason::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ErrorReason {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::ServiceDisabled => serializer.serialize_i32(1),
            Self::BillingDisabled => serializer.serialize_i32(2),
            Self::ApiKeyInvalid => serializer.serialize_i32(3),
            Self::ApiKeyServiceBlocked => serializer.serialize_i32(4),
            Self::ApiKeyHttpReferrerBlocked => serializer.serialize_i32(7),
            Self::ApiKeyIpAddressBlocked => serializer.serialize_i32(8),
            Self::ApiKeyAndroidAppBlocked => serializer.serialize_i32(9),
            Self::ApiKeyIosAppBlocked => serializer.serialize_i32(13),
            Self::RateLimitExceeded => serializer.serialize_i32(5),
            Self::ResourceQuotaExceeded => serializer.serialize_i32(6),
            Self::LocationTaxPolicyViolated => serializer.serialize_i32(10),
            Self::UserProjectDenied => serializer.serialize_i32(11),
            Self::ConsumerSuspended => serializer.serialize_i32(12),
            Self::ConsumerInvalid => serializer.serialize_i32(14),
            Self::SecurityPolicyViolated => serializer.serialize_i32(15),
            Self::AccessTokenExpired => serializer.serialize_i32(16),
            Self::AccessTokenScopeInsufficient => serializer.serialize_i32(17),
            Self::AccountStateInvalid => serializer.serialize_i32(18),
            Self::AccessTokenTypeUnsupported => serializer.serialize_i32(19),
            Self::CredentialsMissing => serializer.serialize_i32(20),
            Self::ResourceProjectInvalid => serializer.serialize_i32(21),
            Self::SessionCookieInvalid => serializer.serialize_i32(23),
            Self::UserBlockedByAdmin => serializer.serialize_i32(24),
            Self::ResourceUsageRestrictionViolated => serializer.serialize_i32(25),
            Self::SystemParameterUnsupported => serializer.serialize_i32(26),
            Self::OrgRestrictionViolation => serializer.serialize_i32(27),
            Self::OrgRestrictionHeaderInvalid => serializer.serialize_i32(28),
            Self::ServiceNotVisible => serializer.serialize_i32(29),
            Self::GcpSuspended => serializer.serialize_i32(30),
            Self::LocationPolicyViolated => serializer.serialize_i32(31),
            Self::MissingOrigin => serializer.serialize_i32(33),
            Self::OverloadedCredentials => serializer.serialize_i32(34),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ErrorReason {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ErrorReason>::new(
            ".google.api.ErrorReason",
        ))
    }
}

/// An indicator of the behavior of a given field (for example, that a field
/// is required in requests, or given as output but ignored as input).
/// This **does not** change the behavior in protocol buffers itself; it only
/// denotes the behavior and may affect how API tooling handles the field.
///
/// Note: This enum **may** receive new values in the future.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum FieldBehavior {
    /// Conventional default for enums. Do not use this.
    Unspecified,
    /// Specifically denotes a field as optional.
    /// While all fields in protocol buffers are optional, this may be specified
    /// for emphasis if appropriate.
    Optional,
    /// Denotes a field as required.
    /// This indicates that the field **must** be provided as part of the request,
    /// and failure to do so will cause an error (usually `INVALID_ARGUMENT`).
    Required,
    /// Denotes a field as output only.
    /// This indicates that the field is provided in responses, but including the
    /// field in a request does nothing (the server *must* ignore it and
    /// *must not* throw an error as a result of the field's presence).
    OutputOnly,
    /// Denotes a field as input only.
    /// This indicates that the field is provided in requests, and the
    /// corresponding field is not included in output.
    InputOnly,
    /// Denotes a field as immutable.
    /// This indicates that the field may be set once in a request to create a
    /// resource, but may not be changed thereafter.
    Immutable,
    /// Denotes that a (repeated) field is an unordered list.
    /// This indicates that the service may provide the elements of the list
    /// in any arbitrary  order, rather than the order the user originally
    /// provided. Additionally, the list's order may or may not be stable.
    UnorderedList,
    /// Denotes that this field returns a non-empty default value if not set.
    /// This indicates that if the user provides the empty value in a request,
    /// a non-empty value will be returned. The user will not be aware of what
    /// non-empty value to expect.
    NonEmptyDefault,
    /// Denotes that the field in a resource (a message annotated with
    /// google.api.resource) is used in the resource name to uniquely identify the
    /// resource. For AIP-compliant APIs, this should only be applied to the
    /// `name` field on the resource.
    ///
    /// This behavior should not be applied to references to other resources within
    /// the message.
    ///
    /// The identifier field of resources often have different field behavior
    /// depending on the request it is embedded in (e.g. for Create methods name
    /// is optional and unused, while for Update methods it is required). Instead
    /// of method-specific annotations, only `IDENTIFIER` is required.
    Identifier,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [FieldBehavior::value] or
    /// [FieldBehavior::name].
    UnknownValue(field_behavior::UnknownValue),
}

#[doc(hidden)]
pub mod field_behavior {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl FieldBehavior {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Optional => std::option::Option::Some(1),
            Self::Required => std::option::Option::Some(2),
            Self::OutputOnly => std::option::Option::Some(3),
            Self::InputOnly => std::option::Option::Some(4),
            Self::Immutable => std::option::Option::Some(5),
            Self::UnorderedList => std::option::Option::Some(6),
            Self::NonEmptyDefault => std::option::Option::Some(7),
            Self::Identifier => std::option::Option::Some(8),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("FIELD_BEHAVIOR_UNSPECIFIED"),
            Self::Optional => std::option::Option::Some("OPTIONAL"),
            Self::Required => std::option::Option::Some("REQUIRED"),
            Self::OutputOnly => std::option::Option::Some("OUTPUT_ONLY"),
            Self::InputOnly => std::option::Option::Some("INPUT_ONLY"),
            Self::Immutable => std::option::Option::Some("IMMUTABLE"),
            Self::UnorderedList => std::option::Option::Some("UNORDERED_LIST"),
            Self::NonEmptyDefault => std::option::Option::Some("NON_EMPTY_DEFAULT"),
            Self::Identifier => std::option::Option::Some("IDENTIFIER"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for FieldBehavior {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for FieldBehavior {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for FieldBehavior {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Optional,
            2 => Self::Required,
            3 => Self::OutputOnly,
            4 => Self::InputOnly,
            5 => Self::Immutable,
            6 => Self::UnorderedList,
            7 => Self::NonEmptyDefault,
            8 => Self::Identifier,
            _ => Self::UnknownValue(field_behavior::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for FieldBehavior {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "FIELD_BEHAVIOR_UNSPECIFIED" => Self::Unspecified,
            "OPTIONAL" => Self::Optional,
            "REQUIRED" => Self::Required,
            "OUTPUT_ONLY" => Self::OutputOnly,
            "INPUT_ONLY" => Self::InputOnly,
            "IMMUTABLE" => Self::Immutable,
            "UNORDERED_LIST" => Self::UnorderedList,
            "NON_EMPTY_DEFAULT" => Self::NonEmptyDefault,
            "IDENTIFIER" => Self::Identifier,
            _ => Self::UnknownValue(field_behavior::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for FieldBehavior {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Optional => serializer.serialize_i32(1),
            Self::Required => serializer.serialize_i32(2),
            Self::OutputOnly => serializer.serialize_i32(3),
            Self::InputOnly => serializer.serialize_i32(4),
            Self::Immutable => serializer.serialize_i32(5),
            Self::UnorderedList => serializer.serialize_i32(6),
            Self::NonEmptyDefault => serializer.serialize_i32(7),
            Self::Identifier => serializer.serialize_i32(8),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for FieldBehavior {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<FieldBehavior>::new(
            ".google.api.FieldBehavior",
        ))
    }
}

/// The launch stage as defined by [Google Cloud Platform
/// Launch Stages](https://cloud.google.com/terms/launch-stages).
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum LaunchStage {
    /// Do not use this default value.
    Unspecified,
    /// The feature is not yet implemented. Users can not use it.
    Unimplemented,
    /// Prelaunch features are hidden from users and are only visible internally.
    Prelaunch,
    /// Early Access features are limited to a closed group of testers. To use
    /// these features, you must sign up in advance and sign a Trusted Tester
    /// agreement (which includes confidentiality provisions). These features may
    /// be unstable, changed in backward-incompatible ways, and are not
    /// guaranteed to be released.
    EarlyAccess,
    /// Alpha is a limited availability test for releases before they are cleared
    /// for widespread use. By Alpha, all significant design issues are resolved
    /// and we are in the process of verifying functionality. Alpha customers
    /// need to apply for access, agree to applicable terms, and have their
    /// projects allowlisted. Alpha releases don't have to be feature complete,
    /// no SLAs are provided, and there are no technical support obligations, but
    /// they will be far enough along that customers can actually use them in
    /// test environments or for limited-use tests -- just like they would in
    /// normal production cases.
    Alpha,
    /// Beta is the point at which we are ready to open a release for any
    /// customer to use. There are no SLA or technical support obligations in a
    /// Beta release. Products will be complete from a feature perspective, but
    /// may have some open outstanding issues. Beta releases are suitable for
    /// limited production use cases.
    Beta,
    /// GA features are open to all developers and are considered stable and
    /// fully qualified for production use.
    Ga,
    /// Deprecated features are scheduled to be shut down and removed. For more
    /// information, see the "Deprecation Policy" section of our [Terms of
    /// Service](https://cloud.google.com/terms/)
    /// and the [Google Cloud Platform Subject to the Deprecation
    /// Policy](https://cloud.google.com/terms/deprecation) documentation.
    Deprecated,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [LaunchStage::value] or
    /// [LaunchStage::name].
    UnknownValue(launch_stage::UnknownValue),
}

#[doc(hidden)]
pub mod launch_stage {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl LaunchStage {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Unimplemented => std::option::Option::Some(6),
            Self::Prelaunch => std::option::Option::Some(7),
            Self::EarlyAccess => std::option::Option::Some(1),
            Self::Alpha => std::option::Option::Some(2),
            Self::Beta => std::option::Option::Some(3),
            Self::Ga => std::option::Option::Some(4),
            Self::Deprecated => std::option::Option::Some(5),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("LAUNCH_STAGE_UNSPECIFIED"),
            Self::Unimplemented => std::option::Option::Some("UNIMPLEMENTED"),
            Self::Prelaunch => std::option::Option::Some("PRELAUNCH"),
            Self::EarlyAccess => std::option::Option::Some("EARLY_ACCESS"),
            Self::Alpha => std::option::Option::Some("ALPHA"),
            Self::Beta => std::option::Option::Some("BETA"),
            Self::Ga => std::option::Option::Some("GA"),
            Self::Deprecated => std::option::Option::Some("DEPRECATED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for LaunchStage {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for LaunchStage {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for LaunchStage {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::EarlyAccess,
            2 => Self::Alpha,
            3 => Self::Beta,
            4 => Self::Ga,
            5 => Self::Deprecated,
            6 => Self::Unimplemented,
            7 => Self::Prelaunch,
            _ => Self::UnknownValue(launch_stage::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for LaunchStage {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "LAUNCH_STAGE_UNSPECIFIED" => Self::Unspecified,
            "UNIMPLEMENTED" => Self::Unimplemented,
            "PRELAUNCH" => Self::Prelaunch,
            "EARLY_ACCESS" => Self::EarlyAccess,
            "ALPHA" => Self::Alpha,
            "BETA" => Self::Beta,
            "GA" => Self::Ga,
            "DEPRECATED" => Self::Deprecated,
            _ => Self::UnknownValue(launch_stage::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for LaunchStage {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Unimplemented => serializer.serialize_i32(6),
            Self::Prelaunch => serializer.serialize_i32(7),
            Self::EarlyAccess => serializer.serialize_i32(1),
            Self::Alpha => serializer.serialize_i32(2),
            Self::Beta => serializer.serialize_i32(3),
            Self::Ga => serializer.serialize_i32(4),
            Self::Deprecated => serializer.serialize_i32(5),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for LaunchStage {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<LaunchStage>::new(
            ".google.api.LaunchStage",
        ))
    }
}
